diff --git a/libavformat/movenc-test.c b/libavformat/movenc-test.c index d72aaec364..8132babbbe 100644 --- a/libavformat/movenc-test.c +++ b/libavformat/movenc-test.c @@ -542,6 +542,40 @@ int main(int argc, char **argv) finish(); + // Test discontinously written fragments with b-frames (where the + // assumption of starting at pts=0 works) but not with audio preroll + // (which can't be guessed). + av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0); + init(1, 0); + mux_gops(1); + init_out("delay-moov-elst-init"); + av_write_frame(ctx, NULL); // Output the moov + close_out(); + memcpy(header, hash, HASH_SIZE); + av_write_frame(ctx, NULL); // Output the first fragment + init_out("delay-moov-elst-second-frag"); + mux_gops(1); + av_write_frame(ctx, NULL); // Output the second fragment + close_out(); + memcpy(content, hash, HASH_SIZE); + finish(); + + av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); + av_dict_set(&opts, "fragment_index", "2", 0); + init(1, 0); + skip_gops(1); + mux_gops(1); // Write the second fragment + init_out("delay-moov-elst-init-discont"); + av_write_frame(ctx, NULL); // Output the moov + close_out(); + check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs"); + init_out("delay-moov-elst-second-frag-discont"); + av_write_frame(ctx, NULL); // Output the second fragment + close_out(); + check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs"); + 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 diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index e2fd059f5d..dffb30c85d 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -16,5 +16,9 @@ ad43cfb415822a0d70db0f11a87ced66 2535 empty-moov-no-elst-no-adjust 64e38d416e9344c8046e37426cdf2807 584 empty-moov-second-frag 64e38d416e9344c8046e37426cdf2807 584 empty-moov-second-frag-discont 64e38d416e9344c8046e37426cdf2807 584 delay-moov-second-frag-discont +6256445b9595de78be493e0faf2bc5d7 1219 delay-moov-elst-init +5bcd7237855218554de38044dbd31cda 704 delay-moov-elst-second-frag +6256445b9595de78be493e0faf2bc5d7 1219 delay-moov-elst-init-discont +5bcd7237855218554de38044dbd31cda 704 delay-moov-elst-second-frag-discont da0d89d03fa601b40f6a653c8314e333 3615 vfr da0d89d03fa601b40f6a653c8314e333 3615 vfr-noduration