]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/tests/movenc.c
Merge commit '390b95b88b2b896b63f257f69e434dfc0111e076'
[ffmpeg] / libavformat / tests / movenc.c
index 41cd4fcdf7221ed20a813b94813f05a8d71e4994..ab871765d9391b612a2eb3252ab1b653fa7de85f 100644 (file)
@@ -243,7 +243,7 @@ static void init(int bf, int audio_preroll)
     init_fps(bf, audio_preroll, 30);
 }
 
-static void mux_frames(int n)
+static void mux_frames(int n, int c)
 {
     int end_frames = frames + n;
     while (1) {
@@ -299,6 +299,12 @@ static void mux_frames(int n)
             continue;
         if (skip_write_audio && pkt.stream_index == 1)
             continue;
+
+        if (c) {
+            pkt.pts += (1LL<<32);
+            pkt.dts += (1LL<<32);
+        }
+
         if (do_interleave)
             av_interleaved_write_frame(ctx, &pkt);
         else
@@ -308,7 +314,7 @@ static void mux_frames(int n)
 
 static void mux_gops(int n)
 {
-    mux_frames(gop_size * n);
+    mux_frames(gop_size * n, 0);
 }
 
 static void skip_gops(int n)
@@ -665,6 +671,21 @@ int main(int argc, char **argv)
     finish();
 
 
+    // Test muxing discontinuous fragments with very large (> (1<<31)) timestamps.
+    av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
+    av_dict_set(&opts, "fragment_index", "2", 0);
+    init(1, 1);
+    signal_init_ts();
+    skip_gops(1);
+    mux_frames(gop_size, 1); // Write the second fragment
+    init_out("delay-moov-elst-signal-init-discont-largets");
+    av_write_frame(ctx, NULL); // Output the moov
+    close_out();
+    init_out("delay-moov-elst-signal-second-frag-discont-largets");
+    av_write_frame(ctx, NULL); // Output the second fragment
+    close_out();
+    finish();
+
     // Test VFR content, with sidx atoms (which declare the pts duration
     // of a fragment, forcing overriding the start pts of the next one).
     // Here, the fragment duration in pts is significantly different from
@@ -680,9 +701,9 @@ int main(int argc, char **argv)
     init_out("vfr");
     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
     init_fps(1, 1, 3);
-    mux_frames(gop_size/2);
+    mux_frames(gop_size/2, 0);
     duration /= 10;
-    mux_frames(gop_size/2);
+    mux_frames(gop_size/2, 0);
     mux_gops(1);
     finish();
     close_out();
@@ -699,9 +720,9 @@ int main(int argc, char **argv)
     init_out("vfr-noduration");
     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
     init_fps(1, 1, 3);
-    mux_frames(gop_size/2);
+    mux_frames(gop_size/2, 0);
     duration /= 10;
-    mux_frames(gop_size/2);
+    mux_frames(gop_size/2, 0);
     mux_gops(1);
     finish();
     close_out();
@@ -729,16 +750,16 @@ int main(int argc, char **argv)
     av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
     av_dict_set(&opts, "frag_duration", "650000", 0);
     init_fps(1, 1, 30);
-    mux_frames(gop_size/2);
+    mux_frames(gop_size/2, 0);
     // Pretend that the packet duration is the normal, even if
     // we actually skip a bunch of frames. (I.e., simulate that
     // we don't know of the framedrop in advance.)
     fake_pkt_duration = duration;
     duration *= 10;
-    mux_frames(1);
+    mux_frames(1, 0);
     fake_pkt_duration = 0;
     duration /= 10;
-    mux_frames(gop_size/2 - 1);
+    mux_frames(gop_size/2 - 1, 0);
     mux_gops(1);
     finish();
     close_out();