diff mbox series

[FFmpeg-devel,v2] lavf/movenc: Write 'dby1' minor brand if Dolby content is being muxed to MP4

Message ID 20210930145140.535362-1-derek.buitenhuis@gmail.com
State Accepted
Commit 68815d67919a6975357ad214d8fe8ac4c886e47c
Headers show
Series [FFmpeg-devel,v2] lavf/movenc: Write 'dby1' minor brand if Dolby content is being muxed to MP4 | expand

Commit Message

Derek Buitenhuis Sept. 30, 2021, 2:51 p.m. UTC
This is as per:
   * mp4ra: http://mp4ra.org/#/brands
   * Dolby Vision muxing spec (which is public):
       https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
 libavformat/movenc.c         | 9 ++++++++-
 tests/ref/fate/copy-trac3074 | 4 ++--
 2 files changed, 10 insertions(+), 3 deletions(-)

Comments

Derek Buitenhuis Oct. 1, 2021, 12:23 p.m. UTC | #1
On 9/30/2021 3:51 PM, Derek Buitenhuis wrote:
> This is as per:
>    * mp4ra: http://mp4ra.org/#/brands
>    * Dolby Vision muxing spec (which is public):
>        https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---
>  libavformat/movenc.c         | 9 ++++++++-
>  tests/ref/fate/copy-trac3074 | 4 ++--
>  2 files changed, 10 insertions(+), 3 deletions(-)

Will push later today if there are no objections.

- Derek
Andreas Rheinhardt Oct. 1, 2021, 12:27 p.m. UTC | #2
Derek Buitenhuis:
> This is as per:
>    * mp4ra: http://mp4ra.org/#/brands
>    * Dolby Vision muxing spec (which is public):
>        https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---
>  libavformat/movenc.c         | 9 ++++++++-
>  tests/ref/fate/copy-trac3074 | 4 ++--
>  2 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index 7650ac5ed3..1a2f24c410 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -4991,7 +4991,7 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>  {
>      MOVMuxContext *mov = s->priv_data;
>      int64_t pos = avio_tell(pb);
> -    int has_h264 = 0, has_av1 = 0, has_video = 0;
> +    int has_h264 = 0, has_av1 = 0, has_video = 0, has_dolby = 0;
>      int i;
>  
>      for (i = 0; i < s->nb_streams; i++) {
> @@ -5004,6 +5004,11 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>              has_h264 = 1;
>          if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
>              has_av1 = 1;
> +        if (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
> +            st->codecpar->codec_id == AV_CODEC_ID_EAC3 ||
> +            st->codecpar->codec_id == AV_CODEC_ID_TRUEHD ||
> +            av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF, NULL))
> +            has_dolby = 1;
>      }
>  
>      avio_wb32(pb, 0); /* size */
> @@ -5029,6 +5034,8 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
>                  ffio_wfourcc(pb, "iso6");
>              if (has_av1)
>                  ffio_wfourcc(pb, "av01");
> +            if (has_dolby)
> +                ffio_wfourcc(pb, "dby1");
>          } else {
>              if (mov->flags & FF_MOV_FLAG_FRAGMENT)
>                  ffio_wfourcc(pb, "iso6");
> diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074
> index e541af03da..4748296c2a 100644
> --- a/tests/ref/fate/copy-trac3074
> +++ b/tests/ref/fate/copy-trac3074
> @@ -1,5 +1,5 @@
> -da6122873fb83ce4340cf5d0ab8d475e *tests/data/fate/copy-trac3074.mp4
> -334012 tests/data/fate/copy-trac3074.mp4
> +452d91e7c6889b787717fef25b6fce43 *tests/data/fate/copy-trac3074.mp4
> +334016 tests/data/fate/copy-trac3074.mp4
>  #tb 0: 1/48000
>  #media_type 0: audio
>  #codec_id 0: eac3
> 

No objection or further comments from me. But I don't know the
underlying specifications.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7650ac5ed3..1a2f24c410 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4991,7 +4991,7 @@  static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
 {
     MOVMuxContext *mov = s->priv_data;
     int64_t pos = avio_tell(pb);
-    int has_h264 = 0, has_av1 = 0, has_video = 0;
+    int has_h264 = 0, has_av1 = 0, has_video = 0, has_dolby = 0;
     int i;
 
     for (i = 0; i < s->nb_streams; i++) {
@@ -5004,6 +5004,11 @@  static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
             has_h264 = 1;
         if (st->codecpar->codec_id == AV_CODEC_ID_AV1)
             has_av1 = 1;
+        if (st->codecpar->codec_id == AV_CODEC_ID_AC3 ||
+            st->codecpar->codec_id == AV_CODEC_ID_EAC3 ||
+            st->codecpar->codec_id == AV_CODEC_ID_TRUEHD ||
+            av_stream_get_side_data(st, AV_PKT_DATA_DOVI_CONF, NULL))
+            has_dolby = 1;
     }
 
     avio_wb32(pb, 0); /* size */
@@ -5029,6 +5034,8 @@  static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
                 ffio_wfourcc(pb, "iso6");
             if (has_av1)
                 ffio_wfourcc(pb, "av01");
+            if (has_dolby)
+                ffio_wfourcc(pb, "dby1");
         } else {
             if (mov->flags & FF_MOV_FLAG_FRAGMENT)
                 ffio_wfourcc(pb, "iso6");
diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074
index e541af03da..4748296c2a 100644
--- a/tests/ref/fate/copy-trac3074
+++ b/tests/ref/fate/copy-trac3074
@@ -1,5 +1,5 @@ 
-da6122873fb83ce4340cf5d0ab8d475e *tests/data/fate/copy-trac3074.mp4
-334012 tests/data/fate/copy-trac3074.mp4
+452d91e7c6889b787717fef25b6fce43 *tests/data/fate/copy-trac3074.mp4
+334016 tests/data/fate/copy-trac3074.mp4
 #tb 0: 1/48000
 #media_type 0: audio
 #codec_id 0: eac3