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.

653 lines
20KB

  1. /*
  2. * Copyright (c) 2012 Nicolas George
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg 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
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include "libavutil/avassert.h"
  21. #include "libavutil/avstring.h"
  22. #include "libavutil/intreadwrite.h"
  23. #include "libavutil/opt.h"
  24. #include "libavutil/parseutils.h"
  25. #include "libavutil/timestamp.h"
  26. #include "avformat.h"
  27. #include "internal.h"
  28. #include "url.h"
  29. typedef enum ConcatMatchMode {
  30. MATCH_ONE_TO_ONE,
  31. MATCH_EXACT_ID,
  32. } ConcatMatchMode;
  33. typedef struct ConcatStream {
  34. AVBitStreamFilterContext *bsf;
  35. int out_stream_index;
  36. } ConcatStream;
  37. typedef struct {
  38. char *url;
  39. int64_t start_time;
  40. int64_t duration;
  41. ConcatStream *streams;
  42. int nb_streams;
  43. } ConcatFile;
  44. typedef struct {
  45. AVClass *class;
  46. ConcatFile *files;
  47. ConcatFile *cur_file;
  48. unsigned nb_files;
  49. AVFormatContext *avf;
  50. int safe;
  51. int seekable;
  52. ConcatMatchMode stream_match_mode;
  53. unsigned auto_convert;
  54. } ConcatContext;
  55. static int concat_probe(AVProbeData *probe)
  56. {
  57. return memcmp(probe->buf, "ffconcat version 1.0", 20) ?
  58. 0 : AVPROBE_SCORE_MAX;
  59. }
  60. static char *get_keyword(uint8_t **cursor)
  61. {
  62. char *ret = *cursor += strspn(*cursor, SPACE_CHARS);
  63. *cursor += strcspn(*cursor, SPACE_CHARS);
  64. if (**cursor) {
  65. *((*cursor)++) = 0;
  66. *cursor += strspn(*cursor, SPACE_CHARS);
  67. }
  68. return ret;
  69. }
  70. static int safe_filename(const char *f)
  71. {
  72. const char *start = f;
  73. for (; *f; f++) {
  74. /* A-Za-z0-9_- */
  75. if (!((unsigned)((*f | 32) - 'a') < 26 ||
  76. (unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) {
  77. if (f == start)
  78. return 0;
  79. else if (*f == '/')
  80. start = f + 1;
  81. else if (*f != '.')
  82. return 0;
  83. }
  84. }
  85. return 1;
  86. }
  87. #define FAIL(retcode) do { ret = (retcode); goto fail; } while(0)
  88. static int add_file(AVFormatContext *avf, char *filename, ConcatFile **rfile,
  89. unsigned *nb_files_alloc)
  90. {
  91. ConcatContext *cat = avf->priv_data;
  92. ConcatFile *file;
  93. char *url = NULL;
  94. const char *proto;
  95. size_t url_len, proto_len;
  96. int ret;
  97. if (cat->safe > 0 && !safe_filename(filename)) {
  98. av_log(avf, AV_LOG_ERROR, "Unsafe file name '%s'\n", filename);
  99. FAIL(AVERROR(EPERM));
  100. }
  101. proto = avio_find_protocol_name(filename);
  102. proto_len = proto ? strlen(proto) : 0;
  103. if (!memcmp(filename, proto, proto_len) &&
  104. (filename[proto_len] == ':' || filename[proto_len] == ',')) {
  105. url = filename;
  106. filename = NULL;
  107. } else {
  108. url_len = strlen(avf->filename) + strlen(filename) + 16;
  109. if (!(url = av_malloc(url_len)))
  110. FAIL(AVERROR(ENOMEM));
  111. ff_make_absolute_url(url, url_len, avf->filename, filename);
  112. av_freep(&filename);
  113. }
  114. if (cat->nb_files >= *nb_files_alloc) {
  115. size_t n = FFMAX(*nb_files_alloc * 2, 16);
  116. ConcatFile *new_files;
  117. if (n <= cat->nb_files || n > SIZE_MAX / sizeof(*cat->files) ||
  118. !(new_files = av_realloc(cat->files, n * sizeof(*cat->files))))
  119. FAIL(AVERROR(ENOMEM));
  120. cat->files = new_files;
  121. *nb_files_alloc = n;
  122. }
  123. file = &cat->files[cat->nb_files++];
  124. memset(file, 0, sizeof(*file));
  125. *rfile = file;
  126. file->url = url;
  127. file->start_time = AV_NOPTS_VALUE;
  128. file->duration = AV_NOPTS_VALUE;
  129. return 0;
  130. fail:
  131. av_free(url);
  132. av_free(filename);
  133. return ret;
  134. }
  135. static int copy_stream_props(AVStream *st, AVStream *source_st)
  136. {
  137. int ret;
  138. if (st->codec->codec_id || !source_st->codec->codec_id) {
  139. if (st->codec->extradata_size < source_st->codec->extradata_size) {
  140. ret = ff_alloc_extradata(st->codec,
  141. source_st->codec->extradata_size);
  142. if (ret < 0)
  143. return ret;
  144. }
  145. memcpy(st->codec->extradata, source_st->codec->extradata,
  146. source_st->codec->extradata_size);
  147. return 0;
  148. }
  149. if ((ret = avcodec_copy_context(st->codec, source_st->codec)) < 0)
  150. return ret;
  151. st->r_frame_rate = source_st->r_frame_rate;
  152. st->avg_frame_rate = source_st->avg_frame_rate;
  153. st->time_base = source_st->time_base;
  154. st->sample_aspect_ratio = source_st->sample_aspect_ratio;
  155. return 0;
  156. }
  157. static int detect_stream_specific(AVFormatContext *avf, int idx)
  158. {
  159. ConcatContext *cat = avf->priv_data;
  160. AVStream *st = cat->avf->streams[idx];
  161. ConcatStream *cs = &cat->cur_file->streams[idx];
  162. AVBitStreamFilterContext *bsf;
  163. if (cat->auto_convert && st->codec->codec_id == AV_CODEC_ID_H264 &&
  164. (st->codec->extradata_size < 4 || AV_RB32(st->codec->extradata) != 1)) {
  165. av_log(cat->avf, AV_LOG_INFO,
  166. "Auto-inserting h264_mp4toannexb bitstream filter\n");
  167. if (!(bsf = av_bitstream_filter_init("h264_mp4toannexb"))) {
  168. av_log(avf, AV_LOG_ERROR, "h264_mp4toannexb bitstream filter "
  169. "required for H.264 streams\n");
  170. return AVERROR_BSF_NOT_FOUND;
  171. }
  172. cs->bsf = bsf;
  173. }
  174. return 0;
  175. }
  176. static int match_streams_one_to_one(AVFormatContext *avf)
  177. {
  178. ConcatContext *cat = avf->priv_data;
  179. AVStream *st;
  180. int i, ret;
  181. for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
  182. if (i < avf->nb_streams) {
  183. st = avf->streams[i];
  184. } else {
  185. if (!(st = avformat_new_stream(avf, NULL)))
  186. return AVERROR(ENOMEM);
  187. }
  188. if ((ret = copy_stream_props(st, cat->avf->streams[i])) < 0)
  189. return ret;
  190. cat->cur_file->streams[i].out_stream_index = i;
  191. }
  192. return 0;
  193. }
  194. static int match_streams_exact_id(AVFormatContext *avf)
  195. {
  196. ConcatContext *cat = avf->priv_data;
  197. AVStream *st;
  198. int i, j, ret;
  199. for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++) {
  200. st = cat->avf->streams[i];
  201. for (j = 0; j < avf->nb_streams; j++) {
  202. if (avf->streams[j]->id == st->id) {
  203. av_log(avf, AV_LOG_VERBOSE,
  204. "Match slave stream #%d with stream #%d id 0x%x\n",
  205. i, j, st->id);
  206. if ((ret = copy_stream_props(avf->streams[j], st)) < 0)
  207. return ret;
  208. cat->cur_file->streams[i].out_stream_index = j;
  209. }
  210. }
  211. }
  212. return 0;
  213. }
  214. static int match_streams(AVFormatContext *avf)
  215. {
  216. ConcatContext *cat = avf->priv_data;
  217. ConcatStream *map;
  218. int i, ret;
  219. if (cat->cur_file->nb_streams >= cat->avf->nb_streams)
  220. return 0;
  221. map = av_realloc(cat->cur_file->streams,
  222. cat->avf->nb_streams * sizeof(*map));
  223. if (!map)
  224. return AVERROR(ENOMEM);
  225. cat->cur_file->streams = map;
  226. memset(map + cat->cur_file->nb_streams, 0,
  227. (cat->avf->nb_streams - cat->cur_file->nb_streams) * sizeof(*map));
  228. for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++)
  229. map[i].out_stream_index = -1;
  230. switch (cat->stream_match_mode) {
  231. case MATCH_ONE_TO_ONE:
  232. ret = match_streams_one_to_one(avf);
  233. break;
  234. case MATCH_EXACT_ID:
  235. ret = match_streams_exact_id(avf);
  236. break;
  237. default:
  238. ret = AVERROR_BUG;
  239. }
  240. if (ret < 0)
  241. return ret;
  242. for (i = cat->cur_file->nb_streams; i < cat->avf->nb_streams; i++)
  243. if ((ret = detect_stream_specific(avf, i)) < 0)
  244. return ret;
  245. cat->cur_file->nb_streams = cat->avf->nb_streams;
  246. return 0;
  247. }
  248. static int open_file(AVFormatContext *avf, unsigned fileno)
  249. {
  250. ConcatContext *cat = avf->priv_data;
  251. ConcatFile *file = &cat->files[fileno];
  252. int ret;
  253. if (cat->avf)
  254. avformat_close_input(&cat->avf);
  255. cat->avf = avformat_alloc_context();
  256. if (!cat->avf)
  257. return AVERROR(ENOMEM);
  258. cat->avf->interrupt_callback = avf->interrupt_callback;
  259. if ((ret = ff_copy_whitelists(cat->avf, avf)) < 0)
  260. return ret;
  261. if ((ret = avformat_open_input(&cat->avf, file->url, NULL, NULL)) < 0 ||
  262. (ret = avformat_find_stream_info(cat->avf, NULL)) < 0) {
  263. av_log(avf, AV_LOG_ERROR, "Impossible to open '%s'\n", file->url);
  264. avformat_close_input(&cat->avf);
  265. return ret;
  266. }
  267. cat->cur_file = file;
  268. if (file->start_time == AV_NOPTS_VALUE)
  269. file->start_time = !fileno ? 0 :
  270. cat->files[fileno - 1].start_time +
  271. cat->files[fileno - 1].duration;
  272. if ((ret = match_streams(avf)) < 0)
  273. return ret;
  274. return 0;
  275. }
  276. static int concat_read_close(AVFormatContext *avf)
  277. {
  278. ConcatContext *cat = avf->priv_data;
  279. unsigned i;
  280. if (cat->avf)
  281. avformat_close_input(&cat->avf);
  282. for (i = 0; i < cat->nb_files; i++) {
  283. av_freep(&cat->files[i].url);
  284. av_freep(&cat->files[i].streams);
  285. }
  286. av_freep(&cat->files);
  287. return 0;
  288. }
  289. static int concat_read_header(AVFormatContext *avf)
  290. {
  291. ConcatContext *cat = avf->priv_data;
  292. uint8_t buf[4096];
  293. uint8_t *cursor, *keyword;
  294. int ret, line = 0, i;
  295. unsigned nb_files_alloc = 0;
  296. ConcatFile *file = NULL;
  297. int64_t time = 0;
  298. while (1) {
  299. if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0)
  300. break;
  301. line++;
  302. cursor = buf;
  303. keyword = get_keyword(&cursor);
  304. if (!*keyword || *keyword == '#')
  305. continue;
  306. if (!strcmp(keyword, "file")) {
  307. char *filename = av_get_token((const char **)&cursor, SPACE_CHARS);
  308. if (!filename) {
  309. av_log(avf, AV_LOG_ERROR, "Line %d: filename required\n", line);
  310. FAIL(AVERROR_INVALIDDATA);
  311. }
  312. if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0)
  313. goto fail;
  314. } else if (!strcmp(keyword, "duration")) {
  315. char *dur_str = get_keyword(&cursor);
  316. int64_t dur;
  317. if (!file) {
  318. av_log(avf, AV_LOG_ERROR, "Line %d: duration without file\n",
  319. line);
  320. FAIL(AVERROR_INVALIDDATA);
  321. }
  322. if ((ret = av_parse_time(&dur, dur_str, 1)) < 0) {
  323. av_log(avf, AV_LOG_ERROR, "Line %d: invalid duration '%s'\n",
  324. line, dur_str);
  325. goto fail;
  326. }
  327. file->duration = dur;
  328. } else if (!strcmp(keyword, "stream")) {
  329. if (!avformat_new_stream(avf, NULL))
  330. FAIL(AVERROR(ENOMEM));
  331. } else if (!strcmp(keyword, "exact_stream_id")) {
  332. if (!avf->nb_streams) {
  333. av_log(avf, AV_LOG_ERROR, "Line %d: exact_stream_id without stream\n",
  334. line);
  335. FAIL(AVERROR_INVALIDDATA);
  336. }
  337. avf->streams[avf->nb_streams - 1]->id =
  338. strtol(get_keyword(&cursor), NULL, 0);
  339. } else if (!strcmp(keyword, "ffconcat")) {
  340. char *ver_kw = get_keyword(&cursor);
  341. char *ver_val = get_keyword(&cursor);
  342. if (strcmp(ver_kw, "version") || strcmp(ver_val, "1.0")) {
  343. av_log(avf, AV_LOG_ERROR, "Line %d: invalid version\n", line);
  344. FAIL(AVERROR_INVALIDDATA);
  345. }
  346. if (cat->safe < 0)
  347. cat->safe = 1;
  348. } else {
  349. av_log(avf, AV_LOG_ERROR, "Line %d: unknown keyword '%s'\n",
  350. line, keyword);
  351. FAIL(AVERROR_INVALIDDATA);
  352. }
  353. }
  354. if (ret < 0)
  355. goto fail;
  356. if (!cat->nb_files)
  357. FAIL(AVERROR_INVALIDDATA);
  358. for (i = 0; i < cat->nb_files; i++) {
  359. if (cat->files[i].start_time == AV_NOPTS_VALUE)
  360. cat->files[i].start_time = time;
  361. else
  362. time = cat->files[i].start_time;
  363. if (cat->files[i].duration == AV_NOPTS_VALUE)
  364. break;
  365. time += cat->files[i].duration;
  366. }
  367. if (i == cat->nb_files) {
  368. avf->duration = time;
  369. cat->seekable = 1;
  370. }
  371. cat->stream_match_mode = avf->nb_streams ? MATCH_EXACT_ID :
  372. MATCH_ONE_TO_ONE;
  373. if ((ret = open_file(avf, 0)) < 0)
  374. goto fail;
  375. return 0;
  376. fail:
  377. concat_read_close(avf);
  378. return ret;
  379. }
  380. static int open_next_file(AVFormatContext *avf)
  381. {
  382. ConcatContext *cat = avf->priv_data;
  383. unsigned fileno = cat->cur_file - cat->files;
  384. if (cat->cur_file->duration == AV_NOPTS_VALUE)
  385. cat->cur_file->duration = cat->avf->duration;
  386. if (++fileno >= cat->nb_files)
  387. return AVERROR_EOF;
  388. return open_file(avf, fileno);
  389. }
  390. static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
  391. {
  392. AVStream *st = avf->streams[cs->out_stream_index];
  393. AVBitStreamFilterContext *bsf;
  394. AVPacket pkt2;
  395. int ret;
  396. av_assert0(cs->out_stream_index >= 0);
  397. for (bsf = cs->bsf; bsf; bsf = bsf->next) {
  398. pkt2 = *pkt;
  399. ret = av_bitstream_filter_filter(bsf, st->codec, NULL,
  400. &pkt2.data, &pkt2.size,
  401. pkt->data, pkt->size,
  402. !!(pkt->flags & AV_PKT_FLAG_KEY));
  403. if (ret < 0) {
  404. av_packet_unref(pkt);
  405. return ret;
  406. }
  407. av_assert0(pkt2.buf);
  408. if (ret == 0 && pkt2.data != pkt->data) {
  409. if ((ret = av_copy_packet(&pkt2, pkt)) < 0) {
  410. av_free(pkt2.data);
  411. return ret;
  412. }
  413. ret = 1;
  414. }
  415. if (ret > 0) {
  416. av_free_packet(pkt);
  417. pkt2.buf = av_buffer_create(pkt2.data, pkt2.size,
  418. av_buffer_default_free, NULL, 0);
  419. if (!pkt2.buf) {
  420. av_free(pkt2.data);
  421. return AVERROR(ENOMEM);
  422. }
  423. }
  424. *pkt = pkt2;
  425. }
  426. return 0;
  427. }
  428. static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
  429. {
  430. ConcatContext *cat = avf->priv_data;
  431. int ret;
  432. int64_t file_start_time, delta;
  433. ConcatStream *cs;
  434. AVStream *st;
  435. if (!cat->avf)
  436. return AVERROR(EIO);
  437. while (1) {
  438. ret = av_read_frame(cat->avf, pkt);
  439. if (ret == AVERROR_EOF) {
  440. if ((ret = open_next_file(avf)) < 0)
  441. return ret;
  442. continue;
  443. }
  444. if (ret < 0)
  445. return ret;
  446. if ((ret = match_streams(avf)) < 0) {
  447. av_packet_unref(pkt);
  448. return ret;
  449. }
  450. cs = &cat->cur_file->streams[pkt->stream_index];
  451. if (cs->out_stream_index < 0) {
  452. av_packet_unref(pkt);
  453. continue;
  454. }
  455. pkt->stream_index = cs->out_stream_index;
  456. break;
  457. }
  458. if ((ret = filter_packet(avf, cs, pkt)))
  459. return ret;
  460. st = cat->avf->streams[pkt->stream_index];
  461. av_log(avf, AV_LOG_DEBUG, "file:%d stream:%d pts:%s pts_time:%s dts:%s dts_time:%s",
  462. (unsigned)(cat->cur_file - cat->files), pkt->stream_index,
  463. av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
  464. av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
  465. file_start_time = cat->avf->start_time;
  466. if (file_start_time == AV_NOPTS_VALUE)
  467. file_start_time = 0;
  468. delta = av_rescale_q(cat->cur_file->start_time - file_start_time,
  469. AV_TIME_BASE_Q,
  470. cat->avf->streams[pkt->stream_index]->time_base);
  471. if (pkt->pts != AV_NOPTS_VALUE)
  472. pkt->pts += delta;
  473. if (pkt->dts != AV_NOPTS_VALUE)
  474. pkt->dts += delta;
  475. av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
  476. av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
  477. av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
  478. return ret;
  479. }
  480. static void rescale_interval(AVRational tb_in, AVRational tb_out,
  481. int64_t *min_ts, int64_t *ts, int64_t *max_ts)
  482. {
  483. *ts = av_rescale_q (* ts, tb_in, tb_out);
  484. *min_ts = av_rescale_q_rnd(*min_ts, tb_in, tb_out,
  485. AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
  486. *max_ts = av_rescale_q_rnd(*max_ts, tb_in, tb_out,
  487. AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
  488. }
  489. static int try_seek(AVFormatContext *avf, int stream,
  490. int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
  491. {
  492. ConcatContext *cat = avf->priv_data;
  493. int64_t t0 = cat->cur_file->start_time - cat->avf->start_time;
  494. ts -= t0;
  495. min_ts = min_ts == INT64_MIN ? INT64_MIN : min_ts - t0;
  496. max_ts = max_ts == INT64_MAX ? INT64_MAX : max_ts - t0;
  497. if (stream >= 0) {
  498. if (stream >= cat->avf->nb_streams)
  499. return AVERROR(EIO);
  500. rescale_interval(AV_TIME_BASE_Q, cat->avf->streams[stream]->time_base,
  501. &min_ts, &ts, &max_ts);
  502. }
  503. return avformat_seek_file(cat->avf, stream, min_ts, ts, max_ts, flags);
  504. }
  505. static int real_seek(AVFormatContext *avf, int stream,
  506. int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
  507. {
  508. ConcatContext *cat = avf->priv_data;
  509. int ret, left, right;
  510. if (stream >= 0) {
  511. if (stream >= avf->nb_streams)
  512. return AVERROR(EINVAL);
  513. rescale_interval(avf->streams[stream]->time_base, AV_TIME_BASE_Q,
  514. &min_ts, &ts, &max_ts);
  515. }
  516. left = 0;
  517. right = cat->nb_files;
  518. while (right - left > 1) {
  519. int mid = (left + right) / 2;
  520. if (ts < cat->files[mid].start_time)
  521. right = mid;
  522. else
  523. left = mid;
  524. }
  525. if ((ret = open_file(avf, left)) < 0)
  526. return ret;
  527. ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
  528. if (ret < 0 &&
  529. left < cat->nb_files - 1 &&
  530. cat->files[left + 1].start_time < max_ts) {
  531. if ((ret = open_file(avf, left + 1)) < 0)
  532. return ret;
  533. ret = try_seek(avf, stream, min_ts, ts, max_ts, flags);
  534. }
  535. return ret;
  536. }
  537. static int concat_seek(AVFormatContext *avf, int stream,
  538. int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
  539. {
  540. ConcatContext *cat = avf->priv_data;
  541. ConcatFile *cur_file_saved = cat->cur_file;
  542. AVFormatContext *cur_avf_saved = cat->avf;
  543. int ret;
  544. if (!cat->seekable)
  545. return AVERROR(ESPIPE); /* XXX: can we use it? */
  546. if (flags & (AVSEEK_FLAG_BYTE | AVSEEK_FLAG_FRAME))
  547. return AVERROR(ENOSYS);
  548. cat->avf = NULL;
  549. if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags)) < 0) {
  550. if (cat->avf)
  551. avformat_close_input(&cat->avf);
  552. cat->avf = cur_avf_saved;
  553. cat->cur_file = cur_file_saved;
  554. } else {
  555. avformat_close_input(&cur_avf_saved);
  556. }
  557. return ret;
  558. }
  559. #define OFFSET(x) offsetof(ConcatContext, x)
  560. #define DEC AV_OPT_FLAG_DECODING_PARAM
  561. static const AVOption options[] = {
  562. { "safe", "enable safe mode",
  563. OFFSET(safe), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, DEC },
  564. { "auto_convert", "automatically convert bitstream format",
  565. OFFSET(auto_convert), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, DEC },
  566. { NULL }
  567. };
  568. static const AVClass concat_class = {
  569. .class_name = "concat demuxer",
  570. .item_name = av_default_item_name,
  571. .option = options,
  572. .version = LIBAVUTIL_VERSION_INT,
  573. };
  574. AVInputFormat ff_concat_demuxer = {
  575. .name = "concat",
  576. .long_name = NULL_IF_CONFIG_SMALL("Virtual concatenation script"),
  577. .priv_data_size = sizeof(ConcatContext),
  578. .read_probe = concat_probe,
  579. .read_header = concat_read_header,
  580. .read_packet = concat_read_packet,
  581. .read_close = concat_read_close,
  582. .read_seek2 = concat_seek,
  583. .priv_class = &concat_class,
  584. };