You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

675 lines
21KB

  1. /*
  2. * Copyright (c) 2015 Martin Storsjo
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "config.h"
  21. #include "libavutil/intreadwrite.h"
  22. #include "libavutil/mathematics.h"
  23. #include "libavutil/md5.h"
  24. #include "avformat.h"
  25. #if HAVE_UNISTD_H
  26. #include <unistd.h>
  27. #endif
  28. #if !HAVE_GETOPT
  29. #include "compat/getopt.c"
  30. #endif
  31. #define HASH_SIZE 16
  32. static const uint8_t h264_extradata[] = {
  33. 0x01, 0x4d, 0x40, 0x1e, 0xff, 0xe1, 0x00, 0x02, 0x67, 0x4d, 0x01, 0x00, 0x02, 0x68, 0xef
  34. };
  35. static const uint8_t aac_extradata[] = {
  36. 0x12, 0x10
  37. };
  38. const char *format = "mp4";
  39. AVFormatContext *ctx;
  40. uint8_t iobuf[32768];
  41. AVDictionary *opts;
  42. int write_file;
  43. const char *cur_name;
  44. FILE* out;
  45. int out_size;
  46. struct AVMD5* md5;
  47. uint8_t hash[HASH_SIZE];
  48. AVStream *video_st, *audio_st;
  49. int64_t audio_dts, video_dts;
  50. int bframes;
  51. int64_t duration;
  52. int64_t audio_duration;
  53. int frames;
  54. int gop_size;
  55. int64_t next_p_pts;
  56. enum AVPictureType last_picture;
  57. int skip_write;
  58. int skip_write_audio;
  59. int clear_duration;
  60. int num_warnings;
  61. int check_faults;
  62. static void count_warnings(void *avcl, int level, const char *fmt, va_list vl)
  63. {
  64. if (level == AV_LOG_WARNING)
  65. num_warnings++;
  66. }
  67. static void init_count_warnings(void)
  68. {
  69. av_log_set_callback(count_warnings);
  70. num_warnings = 0;
  71. }
  72. static void reset_count_warnings(void)
  73. {
  74. av_log_set_callback(av_log_default_callback);
  75. }
  76. static int io_write(void *opaque, uint8_t *buf, int size)
  77. {
  78. out_size += size;
  79. av_md5_update(md5, buf, size);
  80. if (out)
  81. fwrite(buf, 1, size, out);
  82. return size;
  83. }
  84. static void init_out(const char *name)
  85. {
  86. char buf[100];
  87. cur_name = name;
  88. snprintf(buf, sizeof(buf), "%s.%s", cur_name, format);
  89. av_md5_init(md5);
  90. if (write_file) {
  91. out = fopen(buf, "wb");
  92. if (!out)
  93. perror(buf);
  94. }
  95. out_size = 0;
  96. }
  97. static void close_out(void)
  98. {
  99. int i;
  100. av_md5_final(md5, hash);
  101. for (i = 0; i < HASH_SIZE; i++)
  102. printf("%02x", hash[i]);
  103. printf(" %d %s\n", out_size, cur_name);
  104. if (out)
  105. fclose(out);
  106. out = NULL;
  107. }
  108. static void check_func(int value, int line, const char *msg, ...)
  109. {
  110. if (!value) {
  111. va_list ap;
  112. va_start(ap, msg);
  113. printf("%d: ", line);
  114. vprintf(msg, ap);
  115. printf("\n");
  116. check_faults++;
  117. va_end(ap);
  118. }
  119. }
  120. #define check(value, ...) check_func(value, __LINE__, __VA_ARGS__)
  121. static void init_fps(int bf, int audio_preroll, int fps)
  122. {
  123. AVStream *st;
  124. ctx = avformat_alloc_context();
  125. if (!ctx)
  126. exit(1);
  127. ctx->oformat = av_guess_format(format, NULL, NULL);
  128. if (!ctx->oformat)
  129. exit(1);
  130. ctx->pb = avio_alloc_context(iobuf, sizeof(iobuf), AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
  131. if (!ctx->pb)
  132. exit(1);
  133. ctx->flags |= AVFMT_FLAG_BITEXACT;
  134. st = avformat_new_stream(ctx, NULL);
  135. if (!st)
  136. exit(1);
  137. st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
  138. st->codec->codec_id = AV_CODEC_ID_H264;
  139. st->codec->width = 640;
  140. st->codec->height = 480;
  141. st->time_base.num = 1;
  142. st->time_base.den = 30;
  143. st->codec->extradata_size = sizeof(h264_extradata);
  144. st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
  145. if (!st->codec->extradata)
  146. exit(1);
  147. memcpy(st->codec->extradata, h264_extradata, sizeof(h264_extradata));
  148. st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  149. video_st = st;
  150. st = avformat_new_stream(ctx, NULL);
  151. if (!st)
  152. exit(1);
  153. st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
  154. st->codec->codec_id = AV_CODEC_ID_AAC;
  155. st->codec->sample_rate = 44100;
  156. st->codec->channels = 2;
  157. st->time_base.num = 1;
  158. st->time_base.den = 44100;
  159. st->codec->extradata_size = sizeof(aac_extradata);
  160. st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
  161. if (!st->codec->extradata)
  162. exit(1);
  163. memcpy(st->codec->extradata, aac_extradata, sizeof(aac_extradata));
  164. st->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
  165. audio_st = st;
  166. if (avformat_write_header(ctx, &opts) < 0)
  167. exit(1);
  168. av_dict_free(&opts);
  169. frames = 0;
  170. gop_size = 30;
  171. duration = video_st->time_base.den / fps;
  172. audio_duration = 1024LL * audio_st->time_base.den / audio_st->codec->sample_rate;
  173. if (audio_preroll)
  174. audio_preroll = 2048LL * audio_st->time_base.den / audio_st->codec->sample_rate;
  175. bframes = bf;
  176. video_dts = bframes ? -duration : 0;
  177. audio_dts = -audio_preroll;
  178. }
  179. static void init(int bf, int audio_preroll)
  180. {
  181. init_fps(bf, audio_preroll, 30);
  182. }
  183. static void mux_frames(int n)
  184. {
  185. int end_frames = frames + n;
  186. while (1) {
  187. AVPacket pkt;
  188. uint8_t pktdata[4];
  189. av_init_packet(&pkt);
  190. if (av_compare_ts(audio_dts, audio_st->time_base, video_dts, video_st->time_base) < 0) {
  191. pkt.dts = pkt.pts = audio_dts;
  192. pkt.stream_index = 1;
  193. pkt.duration = audio_duration;
  194. audio_dts += audio_duration;
  195. } else {
  196. if (frames == end_frames)
  197. break;
  198. pkt.dts = video_dts;
  199. pkt.stream_index = 0;
  200. pkt.duration = duration;
  201. if ((frames % gop_size) == 0) {
  202. pkt.flags |= AV_PKT_FLAG_KEY;
  203. last_picture = AV_PICTURE_TYPE_I;
  204. pkt.pts = pkt.dts + duration;
  205. video_dts = pkt.pts;
  206. } else {
  207. if (last_picture == AV_PICTURE_TYPE_P) {
  208. last_picture = AV_PICTURE_TYPE_B;
  209. pkt.pts = pkt.dts;
  210. video_dts = next_p_pts;
  211. } else {
  212. last_picture = AV_PICTURE_TYPE_P;
  213. if (((frames + 1) % gop_size) == 0) {
  214. pkt.pts = pkt.dts + duration;
  215. video_dts = pkt.pts;
  216. } else {
  217. next_p_pts = pkt.pts = pkt.dts + 2 * duration;
  218. video_dts += duration;
  219. }
  220. }
  221. }
  222. if (!bframes)
  223. pkt.pts = pkt.dts;
  224. frames++;
  225. }
  226. if (clear_duration)
  227. pkt.duration = 0;
  228. AV_WB32(pktdata, pkt.pts);
  229. pkt.data = pktdata;
  230. pkt.size = 4;
  231. if (skip_write)
  232. continue;
  233. if (skip_write_audio && pkt.stream_index == 1)
  234. continue;
  235. av_write_frame(ctx, &pkt);
  236. }
  237. }
  238. static void mux_gops(int n)
  239. {
  240. mux_frames(gop_size * n);
  241. }
  242. static void skip_gops(int n)
  243. {
  244. skip_write = 1;
  245. mux_gops(n);
  246. skip_write = 0;
  247. }
  248. static void signal_init_ts(void)
  249. {
  250. AVPacket pkt;
  251. av_init_packet(&pkt);
  252. pkt.size = 0;
  253. pkt.data = NULL;
  254. pkt.stream_index = 0;
  255. pkt.dts = video_dts;
  256. pkt.pts = 0;
  257. av_write_frame(ctx, &pkt);
  258. pkt.stream_index = 1;
  259. pkt.dts = pkt.pts = audio_dts;
  260. av_write_frame(ctx, &pkt);
  261. }
  262. static void finish(void)
  263. {
  264. av_write_trailer(ctx);
  265. av_free(ctx->pb);
  266. avformat_free_context(ctx);
  267. ctx = NULL;
  268. }
  269. static void help(void)
  270. {
  271. printf("movenc-test [-w]\n"
  272. "-w write output into files\n");
  273. }
  274. int main(int argc, char **argv)
  275. {
  276. int c;
  277. uint8_t header[HASH_SIZE];
  278. uint8_t content[HASH_SIZE];
  279. int empty_moov_pos;
  280. int prev_pos;
  281. for (;;) {
  282. c = getopt(argc, argv, "wh");
  283. if (c == -1)
  284. break;
  285. switch (c) {
  286. case 'w':
  287. write_file = 1;
  288. break;
  289. default:
  290. case 'h':
  291. help();
  292. return 0;
  293. }
  294. }
  295. av_register_all();
  296. md5 = av_md5_alloc();
  297. if (!md5)
  298. return 1;
  299. // Write a fragmented file with an initial moov that actually contains some
  300. // samples. One moov+mdat with 1 second of data and one moof+mdat with 1
  301. // second of data.
  302. init_out("non-empty-moov");
  303. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  304. init(0, 0);
  305. mux_gops(2);
  306. finish();
  307. close_out();
  308. // Write a similar file, but with b-frames and audio preroll, handled
  309. // via an edit list.
  310. init_out("non-empty-moov-elst");
  311. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  312. av_dict_set(&opts, "use_editlist", "1", 0);
  313. init(1, 1);
  314. mux_gops(2);
  315. finish();
  316. close_out();
  317. // Use b-frames but no audio-preroll, but without an edit list.
  318. // Due to avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO, the dts
  319. // of the first audio packet is > 0, but it is set to zero since edit
  320. // lists aren't used, increasing the duration of the first packet instead.
  321. init_out("non-empty-moov-no-elst");
  322. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  323. av_dict_set(&opts, "use_editlist", "0", 0);
  324. init(1, 0);
  325. mux_gops(2);
  326. finish();
  327. close_out();
  328. format = "ismv";
  329. // Write an ISMV, with b-frames and audio preroll.
  330. init_out("ismv");
  331. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  332. init(1, 1);
  333. mux_gops(2);
  334. finish();
  335. close_out();
  336. format = "mp4";
  337. // An initial moov that doesn't contain any samples, followed by two
  338. // moof+mdat pairs.
  339. init_out("empty-moov");
  340. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  341. init(0, 0);
  342. mux_gops(2);
  343. finish();
  344. close_out();
  345. memcpy(content, hash, HASH_SIZE);
  346. // Similar to the previous one, but with input that doesn't start at
  347. // pts/dts 0. avoid_negative_ts behaves in the same way as
  348. // in non-empty-moov-no-elst above.
  349. init_out("empty-moov-no-elst");
  350. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  351. init(1, 0);
  352. mux_gops(2);
  353. finish();
  354. close_out();
  355. // Same as the previous one, but disable avoid_negative_ts (which
  356. // would require using an edit list, but with empty_moov, one can't
  357. // write a sensible edit list, when the start timestamps aren't known).
  358. // This should trigger a warning - we check that the warning is produced.
  359. init_count_warnings();
  360. init_out("empty-moov-no-elst-no-adjust");
  361. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  362. av_dict_set(&opts, "avoid_negative_ts", "0", 0);
  363. init(1, 0);
  364. mux_gops(2);
  365. finish();
  366. close_out();
  367. reset_count_warnings();
  368. check(num_warnings > 0, "No warnings printed for unhandled start offset");
  369. // Verify that delay_moov produces the same as empty_moov for
  370. // simple input
  371. init_out("delay-moov");
  372. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  373. init(0, 0);
  374. mux_gops(2);
  375. finish();
  376. close_out();
  377. check(!memcmp(hash, content, HASH_SIZE), "delay_moov differs from empty_moov");
  378. // Test writing content that requires an edit list using delay_moov
  379. init_out("delay-moov-elst");
  380. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  381. init(1, 1);
  382. mux_gops(2);
  383. finish();
  384. close_out();
  385. // Test writing a file with one track lacking packets, with delay_moov.
  386. skip_write_audio = 1;
  387. init_out("delay-moov-empty-track");
  388. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  389. init(0, 0);
  390. mux_gops(2);
  391. // The automatic flushing shouldn't output anything, since we're still
  392. // waiting for data for some tracks
  393. check(out_size == 0, "delay_moov flushed prematurely");
  394. // When closed (or manually flushed), all the written data should still
  395. // be output.
  396. finish();
  397. close_out();
  398. check(out_size > 0, "delay_moov didn't output anything");
  399. // Check that manually flushing still outputs things as expected. This
  400. // produces two fragments, while the one above produces only one.
  401. init_out("delay-moov-empty-track-flush");
  402. av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
  403. init(0, 0);
  404. mux_gops(1);
  405. av_write_frame(ctx, NULL); // Force writing the moov
  406. check(out_size > 0, "No moov written");
  407. av_write_frame(ctx, NULL);
  408. mux_gops(1);
  409. av_write_frame(ctx, NULL);
  410. finish();
  411. close_out();
  412. skip_write_audio = 0;
  413. // Verify that the header written by delay_moov when manually flushed
  414. // is identical to the one by empty_moov.
  415. init_out("empty-moov-header");
  416. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  417. init(0, 0);
  418. close_out();
  419. memcpy(header, hash, HASH_SIZE);
  420. init_out("empty-moov-content");
  421. mux_gops(2);
  422. // Written 2 seconds of content, with an automatic flush after 1 second.
  423. check(out_size > 0, "No automatic flush?");
  424. empty_moov_pos = prev_pos = out_size;
  425. // Manually flush the second fragment
  426. av_write_frame(ctx, NULL);
  427. check(out_size > prev_pos, "No second fragment flushed?");
  428. prev_pos = out_size;
  429. // Check that an extra flush doesn't output any more data
  430. av_write_frame(ctx, NULL);
  431. check(out_size == prev_pos, "More data written?");
  432. close_out();
  433. memcpy(content, hash, HASH_SIZE);
  434. // Ignore the trailer written here
  435. finish();
  436. init_out("delay-moov-header");
  437. av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
  438. init(0, 0);
  439. check(out_size == 0, "Output written during init with delay_moov");
  440. mux_gops(1); // Write 1 second of content
  441. av_write_frame(ctx, NULL); // Force writing the moov
  442. close_out();
  443. check(!memcmp(hash, header, HASH_SIZE), "delay_moov header differs from empty_moov");
  444. init_out("delay-moov-content");
  445. av_write_frame(ctx, NULL); // Flush the first fragment
  446. check(out_size == empty_moov_pos, "Manually flushed content differs from automatically flushed, %d vs %d", out_size, empty_moov_pos);
  447. mux_gops(1); // Write the rest of the content
  448. av_write_frame(ctx, NULL); // Flush the second fragment
  449. close_out();
  450. check(!memcmp(hash, content, HASH_SIZE), "delay_moov content differs from empty_moov");
  451. finish();
  452. // Verify that we can produce an identical second fragment without
  453. // writing the first one. First write the reference fragments that
  454. // we want to reproduce.
  455. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash", 0);
  456. init(0, 0);
  457. mux_gops(1);
  458. av_write_frame(ctx, NULL); // Output the first fragment
  459. init_out("empty-moov-second-frag");
  460. mux_gops(1);
  461. av_write_frame(ctx, NULL); // Output the second fragment
  462. close_out();
  463. memcpy(content, hash, HASH_SIZE);
  464. finish();
  465. // Produce the same second fragment without actually writing the first
  466. // one before.
  467. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0);
  468. av_dict_set(&opts, "fragment_index", "2", 0);
  469. av_dict_set(&opts, "avoid_negative_ts", "0", 0);
  470. av_dict_set(&opts, "use_editlist", "0", 0);
  471. init(0, 0);
  472. skip_gops(1);
  473. init_out("empty-moov-second-frag-discont");
  474. mux_gops(1);
  475. av_write_frame(ctx, NULL); // Output the second fragment
  476. close_out();
  477. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  478. finish();
  479. // Produce the same thing by using delay_moov, which requires a slightly
  480. // different call sequence.
  481. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  482. av_dict_set(&opts, "fragment_index", "2", 0);
  483. init(0, 0);
  484. skip_gops(1);
  485. mux_gops(1);
  486. av_write_frame(ctx, NULL); // Output the moov
  487. init_out("delay-moov-second-frag-discont");
  488. av_write_frame(ctx, NULL); // Output the second fragment
  489. close_out();
  490. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  491. finish();
  492. // Test discontinously written fragments with b-frames (where the
  493. // assumption of starting at pts=0 works) but not with audio preroll
  494. // (which can't be guessed).
  495. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0);
  496. init(1, 0);
  497. mux_gops(1);
  498. init_out("delay-moov-elst-init");
  499. av_write_frame(ctx, NULL); // Output the moov
  500. close_out();
  501. memcpy(header, hash, HASH_SIZE);
  502. av_write_frame(ctx, NULL); // Output the first fragment
  503. init_out("delay-moov-elst-second-frag");
  504. mux_gops(1);
  505. av_write_frame(ctx, NULL); // Output the second fragment
  506. close_out();
  507. memcpy(content, hash, HASH_SIZE);
  508. finish();
  509. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  510. av_dict_set(&opts, "fragment_index", "2", 0);
  511. init(1, 0);
  512. skip_gops(1);
  513. mux_gops(1); // Write the second fragment
  514. init_out("delay-moov-elst-init-discont");
  515. av_write_frame(ctx, NULL); // Output the moov
  516. close_out();
  517. check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs");
  518. init_out("delay-moov-elst-second-frag-discont");
  519. av_write_frame(ctx, NULL); // Output the second fragment
  520. close_out();
  521. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  522. finish();
  523. // Test discontinously written fragments with b-frames and audio preroll,
  524. // properly signaled.
  525. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0);
  526. init(1, 1);
  527. mux_gops(1);
  528. init_out("delay-moov-elst-signal-init");
  529. av_write_frame(ctx, NULL); // Output the moov
  530. close_out();
  531. memcpy(header, hash, HASH_SIZE);
  532. av_write_frame(ctx, NULL); // Output the first fragment
  533. init_out("delay-moov-elst-signal-second-frag");
  534. mux_gops(1);
  535. av_write_frame(ctx, NULL); // Output the second fragment
  536. close_out();
  537. memcpy(content, hash, HASH_SIZE);
  538. finish();
  539. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  540. av_dict_set(&opts, "fragment_index", "2", 0);
  541. init(1, 1);
  542. signal_init_ts();
  543. skip_gops(1);
  544. mux_gops(1); // Write the second fragment
  545. init_out("delay-moov-elst-signal-init-discont");
  546. av_write_frame(ctx, NULL); // Output the moov
  547. close_out();
  548. check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs");
  549. init_out("delay-moov-elst-signal-second-frag-discont");
  550. av_write_frame(ctx, NULL); // Output the second fragment
  551. close_out();
  552. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  553. finish();
  554. // Test VFR content, with sidx atoms (which declare the pts duration
  555. // of a fragment, forcing overriding the start pts of the next one).
  556. // Here, the fragment duration in pts is significantly different from
  557. // the duration in dts. The video stream starts at dts=-10,pts=0, and
  558. // the second fragment starts at dts=155,pts=156. The trun duration sum
  559. // of the first fragment is 165, which also is written as
  560. // baseMediaDecodeTime in the tfdt in the second fragment. The sidx for
  561. // the first fragment says earliest_presentation_time = 0 and
  562. // subsegment_duration = 156, which also matches the sidx in the second
  563. // fragment. For the audio stream, the pts and dts durations also don't
  564. // match - the input stream starts at pts=-2048, but that part is excluded
  565. // by the edit list.
  566. init_out("vfr");
  567. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
  568. init_fps(1, 1, 3);
  569. mux_frames(gop_size/2);
  570. duration /= 10;
  571. mux_frames(gop_size/2);
  572. mux_gops(1);
  573. finish();
  574. close_out();
  575. // Test VFR content, with cleared duration fields. In these cases,
  576. // the muxer must guess the duration of the last packet of each
  577. // fragment. As long as the framerate doesn't vary (too much) at the
  578. // fragment edge, it works just fine. Additionally, when automatically
  579. // cutting fragments, the muxer already know the timestamps of the next
  580. // packet for one stream (in most cases the video stream), avoiding
  581. // having to use guesses for that one.
  582. init_count_warnings();
  583. clear_duration = 1;
  584. init_out("vfr-noduration");
  585. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
  586. init_fps(1, 1, 3);
  587. mux_frames(gop_size/2);
  588. duration /= 10;
  589. mux_frames(gop_size/2);
  590. mux_gops(1);
  591. finish();
  592. close_out();
  593. clear_duration = 0;
  594. reset_count_warnings();
  595. check(num_warnings > 0, "No warnings printed for filled in durations");
  596. av_free(md5);
  597. return check_faults > 0 ? 1 : 0;
  598. }