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.

673 lines
20KB

  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. video_st = st;
  149. st = avformat_new_stream(ctx, NULL);
  150. if (!st)
  151. exit(1);
  152. st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
  153. st->codec->codec_id = AV_CODEC_ID_AAC;
  154. st->codec->sample_rate = 44100;
  155. st->codec->channels = 2;
  156. st->time_base.num = 1;
  157. st->time_base.den = 44100;
  158. st->codec->extradata_size = sizeof(aac_extradata);
  159. st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
  160. if (!st->codec->extradata)
  161. exit(1);
  162. memcpy(st->codec->extradata, aac_extradata, sizeof(aac_extradata));
  163. audio_st = st;
  164. if (avformat_write_header(ctx, &opts) < 0)
  165. exit(1);
  166. av_dict_free(&opts);
  167. frames = 0;
  168. gop_size = 30;
  169. duration = video_st->time_base.den / fps;
  170. audio_duration = 1024LL * audio_st->time_base.den / audio_st->codec->sample_rate;
  171. if (audio_preroll)
  172. audio_preroll = 2048LL * audio_st->time_base.den / audio_st->codec->sample_rate;
  173. bframes = bf;
  174. video_dts = bframes ? -duration : 0;
  175. audio_dts = -audio_preroll;
  176. }
  177. static void init(int bf, int audio_preroll)
  178. {
  179. init_fps(bf, audio_preroll, 30);
  180. }
  181. static void mux_frames(int n)
  182. {
  183. int end_frames = frames + n;
  184. while (1) {
  185. AVPacket pkt;
  186. uint8_t pktdata[4];
  187. av_init_packet(&pkt);
  188. if (av_compare_ts(audio_dts, audio_st->time_base, video_dts, video_st->time_base) < 0) {
  189. pkt.dts = pkt.pts = audio_dts;
  190. pkt.stream_index = 1;
  191. pkt.duration = audio_duration;
  192. audio_dts += audio_duration;
  193. } else {
  194. if (frames == end_frames)
  195. break;
  196. pkt.dts = video_dts;
  197. pkt.stream_index = 0;
  198. pkt.duration = duration;
  199. if ((frames % gop_size) == 0) {
  200. pkt.flags |= AV_PKT_FLAG_KEY;
  201. last_picture = AV_PICTURE_TYPE_I;
  202. pkt.pts = pkt.dts + duration;
  203. video_dts = pkt.pts;
  204. } else {
  205. if (last_picture == AV_PICTURE_TYPE_P) {
  206. last_picture = AV_PICTURE_TYPE_B;
  207. pkt.pts = pkt.dts;
  208. video_dts = next_p_pts;
  209. } else {
  210. last_picture = AV_PICTURE_TYPE_P;
  211. if (((frames + 1) % gop_size) == 0) {
  212. pkt.pts = pkt.dts + duration;
  213. video_dts = pkt.pts;
  214. } else {
  215. next_p_pts = pkt.pts = pkt.dts + 2 * duration;
  216. video_dts += duration;
  217. }
  218. }
  219. }
  220. if (!bframes)
  221. pkt.pts = pkt.dts;
  222. frames++;
  223. }
  224. if (clear_duration)
  225. pkt.duration = 0;
  226. AV_WB32(pktdata, pkt.pts);
  227. pkt.data = pktdata;
  228. pkt.size = 4;
  229. if (skip_write)
  230. continue;
  231. if (skip_write_audio && pkt.stream_index == 1)
  232. continue;
  233. av_write_frame(ctx, &pkt);
  234. }
  235. }
  236. static void mux_gops(int n)
  237. {
  238. mux_frames(gop_size * n);
  239. }
  240. static void skip_gops(int n)
  241. {
  242. skip_write = 1;
  243. mux_gops(n);
  244. skip_write = 0;
  245. }
  246. static void signal_init_ts(void)
  247. {
  248. AVPacket pkt;
  249. av_init_packet(&pkt);
  250. pkt.size = 0;
  251. pkt.data = NULL;
  252. pkt.stream_index = 0;
  253. pkt.dts = video_dts;
  254. pkt.pts = 0;
  255. av_write_frame(ctx, &pkt);
  256. pkt.stream_index = 1;
  257. pkt.dts = pkt.pts = audio_dts;
  258. av_write_frame(ctx, &pkt);
  259. }
  260. static void finish(void)
  261. {
  262. av_write_trailer(ctx);
  263. av_free(ctx->pb);
  264. avformat_free_context(ctx);
  265. ctx = NULL;
  266. }
  267. static void help(void)
  268. {
  269. printf("movenc-test [-w]\n"
  270. "-w write output into files\n");
  271. }
  272. int main(int argc, char **argv)
  273. {
  274. int c;
  275. uint8_t header[HASH_SIZE];
  276. uint8_t content[HASH_SIZE];
  277. int empty_moov_pos;
  278. int prev_pos;
  279. for (;;) {
  280. c = getopt(argc, argv, "wh");
  281. if (c == -1)
  282. break;
  283. switch (c) {
  284. case 'w':
  285. write_file = 1;
  286. break;
  287. default:
  288. case 'h':
  289. help();
  290. return 0;
  291. }
  292. }
  293. av_register_all();
  294. md5 = av_md5_alloc();
  295. if (!md5)
  296. return 1;
  297. // Write a fragmented file with an initial moov that actually contains some
  298. // samples. One moov+mdat with 1 second of data and one moof+mdat with 1
  299. // second of data.
  300. init_out("non-empty-moov");
  301. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  302. init(0, 0);
  303. mux_gops(2);
  304. finish();
  305. close_out();
  306. // Write a similar file, but with b-frames and audio preroll, handled
  307. // via an edit list.
  308. init_out("non-empty-moov-elst");
  309. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  310. av_dict_set(&opts, "use_editlist", "1", 0);
  311. init(1, 1);
  312. mux_gops(2);
  313. finish();
  314. close_out();
  315. // Use b-frames but no audio-preroll, but without an edit list.
  316. // Due to avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO, the dts
  317. // of the first audio packet is > 0, but it is set to zero since edit
  318. // lists aren't used, increasing the duration of the first packet instead.
  319. init_out("non-empty-moov-no-elst");
  320. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  321. av_dict_set(&opts, "use_editlist", "0", 0);
  322. init(1, 0);
  323. mux_gops(2);
  324. finish();
  325. close_out();
  326. format = "ismv";
  327. // Write an ISMV, with b-frames and audio preroll.
  328. init_out("ismv");
  329. av_dict_set(&opts, "movflags", "frag_keyframe", 0);
  330. init(1, 1);
  331. mux_gops(2);
  332. finish();
  333. close_out();
  334. format = "mp4";
  335. // An initial moov that doesn't contain any samples, followed by two
  336. // moof+mdat pairs.
  337. init_out("empty-moov");
  338. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  339. init(0, 0);
  340. mux_gops(2);
  341. finish();
  342. close_out();
  343. memcpy(content, hash, HASH_SIZE);
  344. // Similar to the previous one, but with input that doesn't start at
  345. // pts/dts 0. avoid_negative_ts behaves in the same way as
  346. // in non-empty-moov-no-elst above.
  347. init_out("empty-moov-no-elst");
  348. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  349. init(1, 0);
  350. mux_gops(2);
  351. finish();
  352. close_out();
  353. // Same as the previous one, but disable avoid_negative_ts (which
  354. // would require using an edit list, but with empty_moov, one can't
  355. // write a sensible edit list, when the start timestamps aren't known).
  356. // This should trigger a warning - we check that the warning is produced.
  357. init_count_warnings();
  358. init_out("empty-moov-no-elst-no-adjust");
  359. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  360. av_dict_set(&opts, "avoid_negative_ts", "0", 0);
  361. init(1, 0);
  362. mux_gops(2);
  363. finish();
  364. close_out();
  365. reset_count_warnings();
  366. check(num_warnings > 0, "No warnings printed for unhandled start offset");
  367. // Verify that delay_moov produces the same as empty_moov for
  368. // simple input
  369. init_out("delay-moov");
  370. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  371. init(0, 0);
  372. mux_gops(2);
  373. finish();
  374. close_out();
  375. check(!memcmp(hash, content, HASH_SIZE), "delay_moov differs from empty_moov");
  376. // Test writing content that requires an edit list using delay_moov
  377. init_out("delay-moov-elst");
  378. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  379. init(1, 1);
  380. mux_gops(2);
  381. finish();
  382. close_out();
  383. // Test writing a file with one track lacking packets, with delay_moov.
  384. skip_write_audio = 1;
  385. init_out("delay-moov-empty-track");
  386. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
  387. init(0, 0);
  388. mux_gops(2);
  389. // The automatic flushing shouldn't output anything, since we're still
  390. // waiting for data for some tracks
  391. check(out_size == 0, "delay_moov flushed prematurely");
  392. // When closed (or manually flushed), all the written data should still
  393. // be output.
  394. finish();
  395. close_out();
  396. check(out_size > 0, "delay_moov didn't output anything");
  397. // Check that manually flushing still outputs things as expected. This
  398. // produces two fragments, while the one above produces only one.
  399. init_out("delay-moov-empty-track-flush");
  400. av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
  401. init(0, 0);
  402. mux_gops(1);
  403. av_write_frame(ctx, NULL); // Force writing the moov
  404. check(out_size > 0, "No moov written");
  405. av_write_frame(ctx, NULL);
  406. mux_gops(1);
  407. av_write_frame(ctx, NULL);
  408. finish();
  409. close_out();
  410. skip_write_audio = 0;
  411. // Verify that the header written by delay_moov when manually flushed
  412. // is identical to the one by empty_moov.
  413. init_out("empty-moov-header");
  414. av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0);
  415. init(0, 0);
  416. close_out();
  417. memcpy(header, hash, HASH_SIZE);
  418. init_out("empty-moov-content");
  419. mux_gops(2);
  420. // Written 2 seconds of content, with an automatic flush after 1 second.
  421. check(out_size > 0, "No automatic flush?");
  422. empty_moov_pos = prev_pos = out_size;
  423. // Manually flush the second fragment
  424. av_write_frame(ctx, NULL);
  425. check(out_size > prev_pos, "No second fragment flushed?");
  426. prev_pos = out_size;
  427. // Check that an extra flush doesn't output any more data
  428. av_write_frame(ctx, NULL);
  429. check(out_size == prev_pos, "More data written?");
  430. close_out();
  431. memcpy(content, hash, HASH_SIZE);
  432. // Ignore the trailer written here
  433. finish();
  434. init_out("delay-moov-header");
  435. av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0);
  436. init(0, 0);
  437. check(out_size == 0, "Output written during init with delay_moov");
  438. mux_gops(1); // Write 1 second of content
  439. av_write_frame(ctx, NULL); // Force writing the moov
  440. close_out();
  441. check(!memcmp(hash, header, HASH_SIZE), "delay_moov header differs from empty_moov");
  442. init_out("delay-moov-content");
  443. av_write_frame(ctx, NULL); // Flush the first fragment
  444. check(out_size == empty_moov_pos, "Manually flushed content differs from automatically flushed, %d vs %d", out_size, empty_moov_pos);
  445. mux_gops(1); // Write the rest of the content
  446. av_write_frame(ctx, NULL); // Flush the second fragment
  447. close_out();
  448. check(!memcmp(hash, content, HASH_SIZE), "delay_moov content differs from empty_moov");
  449. finish();
  450. // Verify that we can produce an identical second fragment without
  451. // writing the first one. First write the reference fragments that
  452. // we want to reproduce.
  453. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash", 0);
  454. init(0, 0);
  455. mux_gops(1);
  456. av_write_frame(ctx, NULL); // Output the first fragment
  457. init_out("empty-moov-second-frag");
  458. mux_gops(1);
  459. av_write_frame(ctx, NULL); // Output the second fragment
  460. close_out();
  461. memcpy(content, hash, HASH_SIZE);
  462. finish();
  463. // Produce the same second fragment without actually writing the first
  464. // one before.
  465. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0);
  466. av_dict_set(&opts, "fragment_index", "2", 0);
  467. av_dict_set(&opts, "avoid_negative_ts", "0", 0);
  468. av_dict_set(&opts, "use_editlist", "0", 0);
  469. init(0, 0);
  470. skip_gops(1);
  471. init_out("empty-moov-second-frag-discont");
  472. mux_gops(1);
  473. av_write_frame(ctx, NULL); // Output the second fragment
  474. close_out();
  475. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  476. finish();
  477. // Produce the same thing by using delay_moov, which requires a slightly
  478. // different call sequence.
  479. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  480. av_dict_set(&opts, "fragment_index", "2", 0);
  481. init(0, 0);
  482. skip_gops(1);
  483. mux_gops(1);
  484. av_write_frame(ctx, NULL); // Output the moov
  485. init_out("delay-moov-second-frag-discont");
  486. av_write_frame(ctx, NULL); // Output the second fragment
  487. close_out();
  488. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  489. finish();
  490. // Test discontinously written fragments with b-frames (where the
  491. // assumption of starting at pts=0 works) but not with audio preroll
  492. // (which can't be guessed).
  493. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0);
  494. init(1, 0);
  495. mux_gops(1);
  496. init_out("delay-moov-elst-init");
  497. av_write_frame(ctx, NULL); // Output the moov
  498. close_out();
  499. memcpy(header, hash, HASH_SIZE);
  500. av_write_frame(ctx, NULL); // Output the first fragment
  501. init_out("delay-moov-elst-second-frag");
  502. mux_gops(1);
  503. av_write_frame(ctx, NULL); // Output the second fragment
  504. close_out();
  505. memcpy(content, hash, HASH_SIZE);
  506. finish();
  507. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  508. av_dict_set(&opts, "fragment_index", "2", 0);
  509. init(1, 0);
  510. skip_gops(1);
  511. mux_gops(1); // Write the second fragment
  512. init_out("delay-moov-elst-init-discont");
  513. av_write_frame(ctx, NULL); // Output the moov
  514. close_out();
  515. check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs");
  516. init_out("delay-moov-elst-second-frag-discont");
  517. av_write_frame(ctx, NULL); // Output the second fragment
  518. close_out();
  519. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  520. finish();
  521. // Test discontinously written fragments with b-frames and audio preroll,
  522. // properly signaled.
  523. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0);
  524. init(1, 1);
  525. mux_gops(1);
  526. init_out("delay-moov-elst-signal-init");
  527. av_write_frame(ctx, NULL); // Output the moov
  528. close_out();
  529. memcpy(header, hash, HASH_SIZE);
  530. av_write_frame(ctx, NULL); // Output the first fragment
  531. init_out("delay-moov-elst-signal-second-frag");
  532. mux_gops(1);
  533. av_write_frame(ctx, NULL); // Output the second fragment
  534. close_out();
  535. memcpy(content, hash, HASH_SIZE);
  536. finish();
  537. av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0);
  538. av_dict_set(&opts, "fragment_index", "2", 0);
  539. init(1, 1);
  540. signal_init_ts();
  541. skip_gops(1);
  542. mux_gops(1); // Write the second fragment
  543. init_out("delay-moov-elst-signal-init-discont");
  544. av_write_frame(ctx, NULL); // Output the moov
  545. close_out();
  546. check(!memcmp(hash, header, HASH_SIZE), "discontinuously written header differs");
  547. init_out("delay-moov-elst-signal-second-frag-discont");
  548. av_write_frame(ctx, NULL); // Output the second fragment
  549. close_out();
  550. check(!memcmp(hash, content, HASH_SIZE), "discontinuously written fragment differs");
  551. finish();
  552. // Test VFR content, with sidx atoms (which declare the pts duration
  553. // of a fragment, forcing overriding the start pts of the next one).
  554. // Here, the fragment duration in pts is significantly different from
  555. // the duration in dts. The video stream starts at dts=-10,pts=0, and
  556. // the second fragment starts at dts=155,pts=156. The trun duration sum
  557. // of the first fragment is 165, which also is written as
  558. // baseMediaDecodeTime in the tfdt in the second fragment. The sidx for
  559. // the first fragment says earliest_presentation_time = 0 and
  560. // subsegment_duration = 156, which also matches the sidx in the second
  561. // fragment. For the audio stream, the pts and dts durations also don't
  562. // match - the input stream starts at pts=-2048, but that part is excluded
  563. // by the edit list.
  564. init_out("vfr");
  565. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
  566. init_fps(1, 1, 3);
  567. mux_frames(gop_size/2);
  568. duration /= 10;
  569. mux_frames(gop_size/2);
  570. mux_gops(1);
  571. finish();
  572. close_out();
  573. // Test VFR content, with cleared duration fields. In these cases,
  574. // the muxer must guess the duration of the last packet of each
  575. // fragment. As long as the framerate doesn't vary (too much) at the
  576. // fragment edge, it works just fine. Additionally, when automatically
  577. // cutting fragments, the muxer already know the timestamps of the next
  578. // packet for one stream (in most cases the video stream), avoiding
  579. // having to use guesses for that one.
  580. init_count_warnings();
  581. clear_duration = 1;
  582. init_out("vfr-noduration");
  583. av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0);
  584. init_fps(1, 1, 3);
  585. mux_frames(gop_size/2);
  586. duration /= 10;
  587. mux_frames(gop_size/2);
  588. mux_gops(1);
  589. finish();
  590. close_out();
  591. clear_duration = 0;
  592. reset_count_warnings();
  593. check(num_warnings > 0, "No warnings printed for filled in durations");
  594. av_free(md5);
  595. return check_faults > 0 ? 1 : 0;
  596. }