FATE: Add test for muxing discontinuous MP4 fragments with large timestamps

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2016-10-18 16:30:08 +01:00 committed by Michael Niedermayer
parent 18ad44d145
commit dfe7e5501d
2 changed files with 35 additions and 9 deletions

View 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();

View File

@ -108,6 +108,11 @@ c3681590a292cb9ca19a5a982e530166 1219 delay-moov-elst-signal-init-discont
write_data len 996, time 966667, type sync atom sidx
aa5462cc0d2144f72154d9c309edb57d 996 delay-moov-elst-signal-second-frag-discont
write_data len 110, time nopts, type trailer atom -
write_data len 1243, time nopts, type header atom ftyp
dac14c8795d5cbd91ae770c6e2880c62 1243 delay-moov-elst-signal-init-discont-largets
write_data len 996, time 279621233333, type sync atom sidx
41cac4c3df656a87bb38363fdcd745e6 996 delay-moov-elst-signal-second-frag-discont-largets
write_data len 110, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
write_data len 2572, time -333333, type sync atom sidx
write_data len 996, time 5166667, type sync atom sidx