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.

591 lines
20KB

  1. /*
  2. * Copyright (c) 2011, Luca Barbato
  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. /**
  21. * @file generic segmenter
  22. * M3U8 specification can be find here:
  23. * @url{http://tools.ietf.org/id/draft-pantos-http-live-streaming-08.txt}
  24. */
  25. #include <float.h>
  26. #include "avformat.h"
  27. #include "internal.h"
  28. #include "libavutil/log.h"
  29. #include "libavutil/opt.h"
  30. #include "libavutil/avstring.h"
  31. #include "libavutil/parseutils.h"
  32. #include "libavutil/mathematics.h"
  33. typedef enum {
  34. LIST_TYPE_UNDEFINED = -1,
  35. LIST_TYPE_FLAT = 0,
  36. LIST_TYPE_CSV,
  37. LIST_TYPE_M3U8,
  38. LIST_TYPE_EXT, ///< deprecated
  39. LIST_TYPE_NB,
  40. } ListType;
  41. #define SEGMENT_LIST_FLAG_CACHE 1
  42. #define SEGMENT_LIST_FLAG_LIVE 2
  43. typedef struct {
  44. const AVClass *class; /**< Class for private options. */
  45. int segment_idx; ///< index of the segment file to write, starting from 0
  46. int segment_idx_wrap; ///< number after which the index wraps
  47. int segment_count; ///< number of segment files already written
  48. AVOutputFormat *oformat;
  49. AVFormatContext *avf;
  50. char *format; ///< format to use for output segment files
  51. char *list; ///< filename for the segment list file
  52. int list_flags; ///< flags affecting list generation
  53. int list_size; ///< number of entries for the segment list file
  54. double list_max_segment_time; ///< max segment time in the current list
  55. ListType list_type; ///< set the list type
  56. AVIOContext *list_pb; ///< list file put-byte context
  57. char *time_str; ///< segment duration specification string
  58. int64_t time; ///< segment duration
  59. char *times_str; ///< segment times specification string
  60. int64_t *times; ///< list of segment interval specification
  61. int nb_times; ///< number of elments in the times array
  62. char *time_delta_str; ///< approximation value duration used for the segment times
  63. int64_t time_delta;
  64. int individual_header_trailer; /**< Set by a private option. */
  65. int write_header_trailer; /**< Set by a private option. */
  66. int has_video;
  67. double start_time, end_time;
  68. } SegmentContext;
  69. static void print_csv_escaped_str(AVIOContext *ctx, const char *str)
  70. {
  71. int needs_quoting = !!str[strcspn(str, "\",\n\r")];
  72. if (needs_quoting)
  73. avio_w8(ctx, '"');
  74. for (; *str; str++) {
  75. if (*str == '"')
  76. avio_w8(ctx, '"');
  77. avio_w8(ctx, *str);
  78. }
  79. if (needs_quoting)
  80. avio_w8(ctx, '"');
  81. }
  82. static int segment_mux_init(AVFormatContext *s)
  83. {
  84. SegmentContext *seg = s->priv_data;
  85. AVFormatContext *oc;
  86. int i;
  87. seg->avf = oc = avformat_alloc_context();
  88. if (!oc)
  89. return AVERROR(ENOMEM);
  90. oc->oformat = seg->oformat;
  91. oc->interrupt_callback = s->interrupt_callback;
  92. for (i = 0; i < s->nb_streams; i++) {
  93. AVStream *st;
  94. AVCodecContext *icodec, *ocodec;
  95. if (!(st = avformat_new_stream(oc, NULL)))
  96. return AVERROR(ENOMEM);
  97. icodec = s->streams[i]->codec;
  98. ocodec = st->codec;
  99. avcodec_copy_context(ocodec, icodec);
  100. if (!oc->oformat->codec_tag ||
  101. av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == ocodec->codec_id ||
  102. av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) {
  103. ocodec->codec_tag = icodec->codec_tag;
  104. } else {
  105. ocodec->codec_tag = 0;
  106. }
  107. st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
  108. }
  109. return 0;
  110. }
  111. static int segment_start(AVFormatContext *s, int write_header)
  112. {
  113. SegmentContext *seg = s->priv_data;
  114. AVFormatContext *oc = seg->avf;
  115. int err = 0;
  116. if (write_header) {
  117. avformat_free_context(oc);
  118. seg->avf = NULL;
  119. if ((err = segment_mux_init(s)) < 0)
  120. return err;
  121. oc = seg->avf;
  122. }
  123. seg->segment_idx++;
  124. if (seg->segment_idx_wrap)
  125. seg->segment_idx %= seg->segment_idx_wrap;
  126. if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
  127. s->filename, seg->segment_idx) < 0) {
  128. av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", s->filename);
  129. return AVERROR(EINVAL);
  130. }
  131. seg->segment_count++;
  132. if ((err = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
  133. &s->interrupt_callback, NULL)) < 0)
  134. return err;
  135. if (oc->oformat->priv_class && oc->priv_data)
  136. av_opt_set(oc->priv_data, "resend_headers", "1", 0); /* mpegts specific */
  137. if (write_header) {
  138. if ((err = avformat_write_header(oc, NULL)) < 0)
  139. return err;
  140. }
  141. return 0;
  142. }
  143. static int segment_list_open(AVFormatContext *s)
  144. {
  145. SegmentContext *seg = s->priv_data;
  146. int ret;
  147. ret = avio_open2(&seg->list_pb, seg->list, AVIO_FLAG_WRITE,
  148. &s->interrupt_callback, NULL);
  149. if (ret < 0)
  150. return ret;
  151. seg->list_max_segment_time = 0;
  152. if (seg->list_type == LIST_TYPE_M3U8) {
  153. avio_printf(seg->list_pb, "#EXTM3U\n");
  154. avio_printf(seg->list_pb, "#EXT-X-VERSION:3\n");
  155. avio_printf(seg->list_pb, "#EXT-X-MEDIA-SEQUENCE:%d\n", seg->segment_idx);
  156. avio_printf(seg->list_pb, "#EXT-X-ALLOWCACHE:%d\n",
  157. !!(seg->list_flags & SEGMENT_LIST_FLAG_CACHE));
  158. if (seg->list_flags & SEGMENT_LIST_FLAG_LIVE)
  159. avio_printf(seg->list_pb,
  160. "#EXT-X-TARGETDURATION:%"PRId64"\n", seg->time / 1000000);
  161. }
  162. return ret;
  163. }
  164. static void segment_list_close(AVFormatContext *s)
  165. {
  166. SegmentContext *seg = s->priv_data;
  167. if (seg->list_type == LIST_TYPE_M3U8) {
  168. if (!(seg->list_flags & SEGMENT_LIST_FLAG_LIVE))
  169. avio_printf(seg->list_pb, "#EXT-X-TARGETDURATION:%d\n",
  170. (int)ceil(seg->list_max_segment_time));
  171. avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
  172. }
  173. avio_close(seg->list_pb);
  174. }
  175. static int segment_end(AVFormatContext *s, int write_trailer)
  176. {
  177. SegmentContext *seg = s->priv_data;
  178. AVFormatContext *oc = seg->avf;
  179. int ret = 0;
  180. av_write_frame(oc, NULL); /* Flush any buffered data (fragmented mp4) */
  181. if (write_trailer)
  182. ret = av_write_trailer(oc);
  183. if (ret < 0)
  184. av_log(s, AV_LOG_ERROR, "Failure occurred when ending segment '%s'\n",
  185. oc->filename);
  186. if (seg->list) {
  187. if (seg->list_size && !(seg->segment_count % seg->list_size)) {
  188. segment_list_close(s);
  189. if ((ret = segment_list_open(s)) < 0)
  190. goto end;
  191. }
  192. if (seg->list_type == LIST_TYPE_FLAT) {
  193. avio_printf(seg->list_pb, "%s\n", oc->filename);
  194. } else if (seg->list_type == LIST_TYPE_CSV || seg->list_type == LIST_TYPE_EXT) {
  195. print_csv_escaped_str(seg->list_pb, oc->filename);
  196. avio_printf(seg->list_pb, ",%f,%f\n", seg->start_time, seg->end_time);
  197. } else if (seg->list_type == LIST_TYPE_M3U8) {
  198. avio_printf(seg->list_pb, "#EXTINF:%f,\n%s\n",
  199. seg->end_time - seg->start_time, oc->filename);
  200. }
  201. seg->list_max_segment_time = FFMAX(seg->end_time - seg->start_time, seg->list_max_segment_time);
  202. avio_flush(seg->list_pb);
  203. }
  204. end:
  205. avio_close(oc->pb);
  206. return ret;
  207. }
  208. static int parse_times(void *log_ctx, int64_t **times, int *nb_times,
  209. const char *times_str)
  210. {
  211. char *p;
  212. int i, ret = 0;
  213. char *times_str1 = av_strdup(times_str);
  214. char *saveptr = NULL;
  215. if (!times_str1)
  216. return AVERROR(ENOMEM);
  217. #define FAIL(err) ret = err; goto end
  218. *nb_times = 1;
  219. for (p = times_str1; *p; p++)
  220. if (*p == ',')
  221. (*nb_times)++;
  222. *times = av_malloc(sizeof(**times) * *nb_times);
  223. if (!*times) {
  224. av_log(log_ctx, AV_LOG_ERROR, "Could not allocate forced times array\n");
  225. FAIL(AVERROR(ENOMEM));
  226. }
  227. p = times_str1;
  228. for (i = 0; i < *nb_times; i++) {
  229. int64_t t;
  230. char *tstr = av_strtok(p, ",", &saveptr);
  231. p = NULL;
  232. if (!tstr || !tstr[0]) {
  233. av_log(log_ctx, AV_LOG_ERROR, "Empty time specification in times list %s\n",
  234. times_str);
  235. FAIL(AVERROR(EINVAL));
  236. }
  237. ret = av_parse_time(&t, tstr, 1);
  238. if (ret < 0) {
  239. av_log(log_ctx, AV_LOG_ERROR,
  240. "Invalid time duration specification '%s' in times list %s\n", tstr, times_str);
  241. FAIL(AVERROR(EINVAL));
  242. }
  243. (*times)[i] = t;
  244. /* check on monotonicity */
  245. if (i && (*times)[i-1] > (*times)[i]) {
  246. av_log(log_ctx, AV_LOG_ERROR,
  247. "Specified time %f is greater than the following time %f\n",
  248. (float)((*times)[i])/1000000, (float)((*times)[i-1])/1000000);
  249. FAIL(AVERROR(EINVAL));
  250. }
  251. }
  252. end:
  253. av_free(times_str1);
  254. return ret;
  255. }
  256. static int open_null_ctx(AVIOContext **ctx)
  257. {
  258. int buf_size = 32768;
  259. uint8_t *buf = av_malloc(buf_size);
  260. if (!buf)
  261. return AVERROR(ENOMEM);
  262. *ctx = avio_alloc_context(buf, buf_size, AVIO_FLAG_WRITE, NULL, NULL, NULL, NULL);
  263. if (!*ctx) {
  264. av_free(buf);
  265. return AVERROR(ENOMEM);
  266. }
  267. return 0;
  268. }
  269. static void close_null_ctx(AVIOContext *pb)
  270. {
  271. av_free(pb->buffer);
  272. av_free(pb);
  273. }
  274. static int seg_write_header(AVFormatContext *s)
  275. {
  276. SegmentContext *seg = s->priv_data;
  277. AVFormatContext *oc = NULL;
  278. int ret, i;
  279. seg->segment_count = 0;
  280. if (!seg->write_header_trailer)
  281. seg->individual_header_trailer = 0;
  282. if (seg->time_str && seg->times_str) {
  283. av_log(s, AV_LOG_ERROR,
  284. "segment_time and segment_times options are mutually exclusive, select just one of them\n");
  285. return AVERROR(EINVAL);
  286. }
  287. if ((seg->list_flags & SEGMENT_LIST_FLAG_LIVE) && seg->times_str) {
  288. av_log(s, AV_LOG_ERROR,
  289. "segment_flags +live and segment_times options are mutually exclusive:"
  290. "specify -segment_time if you want a live-friendly list\n");
  291. return AVERROR(EINVAL);
  292. }
  293. if (seg->times_str) {
  294. if ((ret = parse_times(s, &seg->times, &seg->nb_times, seg->times_str)) < 0)
  295. return ret;
  296. } else {
  297. /* set default value if not specified */
  298. if (!seg->time_str)
  299. seg->time_str = av_strdup("2");
  300. if ((ret = av_parse_time(&seg->time, seg->time_str, 1)) < 0) {
  301. av_log(s, AV_LOG_ERROR,
  302. "Invalid time duration specification '%s' for segment_time option\n",
  303. seg->time_str);
  304. return ret;
  305. }
  306. }
  307. if (seg->time_delta_str) {
  308. if ((ret = av_parse_time(&seg->time_delta, seg->time_delta_str, 1)) < 0) {
  309. av_log(s, AV_LOG_ERROR,
  310. "Invalid time duration specification '%s' for delta option\n",
  311. seg->time_delta_str);
  312. return ret;
  313. }
  314. }
  315. if (seg->list) {
  316. if (seg->list_type == LIST_TYPE_UNDEFINED) {
  317. if (av_match_ext(seg->list, "csv" )) seg->list_type = LIST_TYPE_CSV;
  318. else if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT;
  319. else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8;
  320. else seg->list_type = LIST_TYPE_FLAT;
  321. }
  322. if ((ret = segment_list_open(s)) < 0)
  323. goto fail;
  324. }
  325. if (seg->list_type == LIST_TYPE_EXT)
  326. av_log(s, AV_LOG_WARNING, "'ext' list type option is deprecated in favor of 'csv'\n");
  327. for (i = 0; i < s->nb_streams; i++)
  328. seg->has_video +=
  329. (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO);
  330. if (seg->has_video > 1)
  331. av_log(s, AV_LOG_WARNING,
  332. "More than a single video stream present, "
  333. "expect issues decoding it.\n");
  334. seg->oformat = av_guess_format(seg->format, s->filename, NULL);
  335. if (!seg->oformat) {
  336. ret = AVERROR_MUXER_NOT_FOUND;
  337. goto fail;
  338. }
  339. if (seg->oformat->flags & AVFMT_NOFILE) {
  340. av_log(s, AV_LOG_ERROR, "format %s not supported.\n",
  341. seg->oformat->name);
  342. ret = AVERROR(EINVAL);
  343. goto fail;
  344. }
  345. if ((ret = segment_mux_init(s)) < 0)
  346. goto fail;
  347. oc = seg->avf;
  348. if (av_get_frame_filename(oc->filename, sizeof(oc->filename),
  349. s->filename, seg->segment_idx) < 0) {
  350. ret = AVERROR(EINVAL);
  351. goto fail;
  352. }
  353. seg->segment_count++;
  354. if (seg->write_header_trailer) {
  355. if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
  356. &s->interrupt_callback, NULL)) < 0)
  357. goto fail;
  358. } else {
  359. if ((ret = open_null_ctx(&oc->pb)) < 0)
  360. goto fail;
  361. }
  362. if ((ret = avformat_write_header(oc, NULL)) < 0) {
  363. avio_close(oc->pb);
  364. goto fail;
  365. }
  366. if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0)
  367. s->avoid_negative_ts = 1;
  368. if (!seg->write_header_trailer) {
  369. close_null_ctx(oc->pb);
  370. if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE,
  371. &s->interrupt_callback, NULL)) < 0)
  372. goto fail;
  373. }
  374. fail:
  375. if (ret) {
  376. if (seg->list)
  377. segment_list_close(s);
  378. if (seg->avf)
  379. avformat_free_context(seg->avf);
  380. }
  381. return ret;
  382. }
  383. static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
  384. {
  385. SegmentContext *seg = s->priv_data;
  386. AVFormatContext *oc = seg->avf;
  387. AVStream *st = s->streams[pkt->stream_index];
  388. int64_t end_pts;
  389. int ret;
  390. if (seg->times) {
  391. end_pts = seg->segment_count <= seg->nb_times ?
  392. seg->times[seg->segment_count-1] : INT64_MAX;
  393. } else {
  394. end_pts = seg->time * seg->segment_count;
  395. }
  396. /* if the segment has video, start a new segment *only* with a key video frame */
  397. if ((st->codec->codec_type == AVMEDIA_TYPE_VIDEO || !seg->has_video) &&
  398. av_compare_ts(pkt->pts, st->time_base,
  399. end_pts-seg->time_delta, AV_TIME_BASE_Q) >= 0 &&
  400. pkt->flags & AV_PKT_FLAG_KEY) {
  401. av_log(s, AV_LOG_DEBUG, "Next segment starts with packet stream:%d pts:%"PRId64" pts_time:%f\n",
  402. pkt->stream_index, pkt->pts, pkt->pts * av_q2d(st->time_base));
  403. ret = segment_end(s, seg->individual_header_trailer);
  404. if (!ret)
  405. ret = segment_start(s, seg->individual_header_trailer);
  406. if (ret)
  407. goto fail;
  408. oc = seg->avf;
  409. seg->start_time = (double)pkt->pts * av_q2d(st->time_base);
  410. } else if (pkt->pts != AV_NOPTS_VALUE) {
  411. seg->end_time = FFMAX(seg->end_time,
  412. (double)(pkt->pts + pkt->duration) * av_q2d(st->time_base));
  413. }
  414. ret = ff_write_chained(oc, pkt->stream_index, pkt, s);
  415. fail:
  416. if (ret < 0) {
  417. if (seg->list)
  418. avio_close(seg->list_pb);
  419. avformat_free_context(oc);
  420. }
  421. return ret;
  422. }
  423. static int seg_write_trailer(struct AVFormatContext *s)
  424. {
  425. SegmentContext *seg = s->priv_data;
  426. AVFormatContext *oc = seg->avf;
  427. int ret;
  428. if (!seg->write_header_trailer) {
  429. if ((ret = segment_end(s, 0)) < 0)
  430. goto fail;
  431. open_null_ctx(&oc->pb);
  432. ret = av_write_trailer(oc);
  433. close_null_ctx(oc->pb);
  434. } else {
  435. ret = segment_end(s, 1);
  436. }
  437. fail:
  438. if (seg->list)
  439. segment_list_close(s);
  440. av_opt_free(seg);
  441. av_freep(&seg->times);
  442. avformat_free_context(oc);
  443. return ret;
  444. }
  445. #define OFFSET(x) offsetof(SegmentContext, x)
  446. #define E AV_OPT_FLAG_ENCODING_PARAM
  447. static const AVOption options[] = {
  448. { "segment_format", "set container format used for the segments", OFFSET(format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
  449. { "segment_list", "set the segment list filename", OFFSET(list), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
  450. { "segment_list_flags","set flags affecting segment list generation", OFFSET(list_flags), AV_OPT_TYPE_FLAGS, {.i64 = SEGMENT_LIST_FLAG_CACHE }, 0, UINT_MAX, E, "list_flags"},
  451. { "cache", "allow list caching", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_LIST_FLAG_CACHE }, INT_MIN, INT_MAX, E, "list_flags"},
  452. { "live", "enable live-friendly list generation (useful for HLS)", 0, AV_OPT_TYPE_CONST, {.i64 = SEGMENT_LIST_FLAG_LIVE }, INT_MIN, INT_MAX, E, "list_flags"},
  453. { "segment_list_size", "set the maximum number of playlist entries", OFFSET(list_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
  454. { "segment_list_type", "set the segment list type", OFFSET(list_type), AV_OPT_TYPE_INT, {.i64 = LIST_TYPE_UNDEFINED}, -1, LIST_TYPE_NB-1, E, "list_type" },
  455. { "flat", "flat format", 0, AV_OPT_TYPE_CONST, {.i64=LIST_TYPE_FLAT }, INT_MIN, INT_MAX, 0, "list_type" },
  456. { "csv", "csv format", 0, AV_OPT_TYPE_CONST, {.i64=LIST_TYPE_CSV }, INT_MIN, INT_MAX, 0, "list_type" },
  457. { "ext", "extended format", 0, AV_OPT_TYPE_CONST, {.i64=LIST_TYPE_EXT }, INT_MIN, INT_MAX, 0, "list_type" },
  458. { "m3u8", "M3U8 format", 0, AV_OPT_TYPE_CONST, {.i64=LIST_TYPE_M3U8 }, INT_MIN, INT_MAX, 0, "list_type" },
  459. { "hls", "Apple HTTP Live Streaming compatible", 0, AV_OPT_TYPE_CONST, {.i64=LIST_TYPE_M3U8 }, INT_MIN, INT_MAX, 0, "list_type" },
  460. { "segment_time", "set segment duration", OFFSET(time_str),AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E },
  461. { "segment_time_delta","set approximation value used for the segment times", OFFSET(time_delta_str), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, E },
  462. { "segment_times", "set segment split time points", OFFSET(times_str),AV_OPT_TYPE_STRING,{.str = NULL}, 0, 0, E },
  463. { "segment_wrap", "set number after which the index wraps", OFFSET(segment_idx_wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E },
  464. { "individual_header_trailer", "write header/trailer to each segment", OFFSET(individual_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
  465. { "write_header_trailer", "write a header to the first segment and a trailer to the last one", OFFSET(write_header_trailer), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
  466. { NULL },
  467. };
  468. static const AVClass seg_class = {
  469. .class_name = "segment muxer",
  470. .item_name = av_default_item_name,
  471. .option = options,
  472. .version = LIBAVUTIL_VERSION_INT,
  473. };
  474. AVOutputFormat ff_segment_muxer = {
  475. .name = "segment",
  476. .long_name = NULL_IF_CONFIG_SMALL("segment"),
  477. .priv_data_size = sizeof(SegmentContext),
  478. .flags = AVFMT_NOFILE|AVFMT_GLOBALHEADER,
  479. .write_header = seg_write_header,
  480. .write_packet = seg_write_packet,
  481. .write_trailer = seg_write_trailer,
  482. .priv_class = &seg_class,
  483. };
  484. static const AVClass sseg_class = {
  485. .class_name = "stream_segment muxer",
  486. .item_name = av_default_item_name,
  487. .option = options,
  488. .version = LIBAVUTIL_VERSION_INT,
  489. };
  490. AVOutputFormat ff_stream_segment_muxer = {
  491. .name = "stream_segment,ssegment",
  492. .long_name = NULL_IF_CONFIG_SMALL("streaming segment muxer"),
  493. .priv_data_size = sizeof(SegmentContext),
  494. .flags = AVFMT_NOFILE,
  495. .write_header = seg_write_header,
  496. .write_packet = seg_write_packet,
  497. .write_trailer = seg_write_trailer,
  498. .priv_class = &sseg_class,
  499. };