[FFmpeg-devel] [PATCH 3/3 v2] avformat/movenc: set delay_moov flag when writing DASH

James Almer jamrial at gmail.com
Fri Nov 22 00:41:20 EET 2024


Instead of expecting the DASH muxer manually setting this, just do it here.
This is required to write a simple edit list for audio tracks with triming
samples, where negative CTS offsets can't be used.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/movenc.c       |  2 +-
 libavformat/tests/movenc.c |  6 +++---
 tests/ref/fate/movenc      | 14 +++++++-------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7cdec28835..cc67e274e8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -7641,7 +7641,7 @@ static int mov_init(AVFormatContext *s)
                       FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS;
     if (mov->flags & FF_MOV_FLAG_DASH)
         mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
-                      FF_MOV_FLAG_DEFAULT_BASE_MOOF;
+                      FF_MOV_FLAG_DEFAULT_BASE_MOOF | FF_MOV_FLAG_DELAY_MOOV;
     if (mov->flags & FF_MOV_FLAG_CMAF)
         mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
                       FF_MOV_FLAG_DEFAULT_BASE_MOOF | FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS;
diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c
index 2fd5c67e76..e0e8b3b5fc 100644
--- a/libavformat/tests/movenc.c
+++ b/libavformat/tests/movenc.c
@@ -598,7 +598,7 @@ int main(int argc, char **argv)
     // Verify that we can produce an identical second fragment without
     // writing the first one. First write the reference fragments that
     // we want to reproduce.
-    av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+dash", 0);
+    av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+default_base_moof", 0);
     init(0, 0);
     mux_gops(1);
     av_write_frame(ctx, NULL); // Output the first fragment
@@ -611,7 +611,7 @@ int main(int argc, char **argv)
 
     // Produce the same second fragment without actually writing the first
     // one before.
-    av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+dash+frag_discont", 0);
+    av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+default_base_moof+frag_discont", 0);
     av_dict_set(&opts, "fragment_index", "2", 0);
     av_dict_set(&opts, "avoid_negative_ts", "disabled", 0);
     av_dict_set(&opts, "use_editlist", "0", 0);
@@ -626,7 +626,7 @@ int main(int argc, char **argv)
 
     // Produce the same thing by using delay_moov, which requires a slightly
     // different call sequence.
-    av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash+frag_discont", 0);
+    av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+default_base_moof+frag_discont", 0);
     av_dict_set(&opts, "fragment_index", "2", 0);
     init(0, 0);
     skip_gops(1);
diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc
index 5c12aeb29f..085a7afc1d 100644
--- a/tests/ref/fate/movenc
+++ b/tests/ref/fate/movenc
@@ -73,18 +73,18 @@ write_data len 788, time 1000000, type sync atom moof
 write_data len 148, time nopts, type trailer atom -
 write_data len 28, time nopts, type header atom -
 write_data len 1123, time nopts, type header atom -
-write_data len 884, time 0, type sync atom sidx
-write_data len 876, time 1000000, type sync atom sidx
-c0307f99a2a362205b7e3d65b1066f86 876 empty-moov-second-frag
+write_data len 780, time 0, type sync atom moof
+write_data len 772, time 1000000, type sync atom moof
+01055745b1f768dbe2d3a070dd58a8f9 772 empty-moov-second-frag
 write_data len 148, time nopts, type trailer atom -
 write_data len 28, time nopts, type header atom -
 write_data len 1123, time nopts, type header atom -
-write_data len 876, time 1000000, type sync atom sidx
-c0307f99a2a362205b7e3d65b1066f86 876 empty-moov-second-frag-discont
+write_data len 772, time 1000000, type sync atom moof
+01055745b1f768dbe2d3a070dd58a8f9 772 empty-moov-second-frag-discont
 write_data len 110, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom -
-write_data len 876, time 1000000, type sync atom sidx
-c0307f99a2a362205b7e3d65b1066f86 876 delay-moov-second-frag-discont
+write_data len 772, time 1000000, type sync atom moof
+01055745b1f768dbe2d3a070dd58a8f9 772 delay-moov-second-frag-discont
 write_data len 110, time nopts, type trailer atom -
 write_data len 1223, time nopts, type header atom ftyp
 b3811928793ed0749927eb2f7958421c 1223 delay-moov-elst-init
-- 
2.47.0



More information about the ffmpeg-devel mailing list