diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-08-16 00:16:28 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-08-18 12:31:49 +0200 |
commit | 1c522e3868937a2cda14607054192e48bec132d1 (patch) | |
tree | 76325704b270dccf4c531519b673a973be040a34 /libavformat/segment.c | |
parent | dc7e4d685f9e105003da55ca0ca25e54c53eb4f3 (diff) | |
download | ffmpeg-1c522e3868937a2cda14607054192e48bec132d1.tar.gz |
lavf/segment: guess list type from list filename suffix
Diffstat (limited to 'libavformat/segment.c')
-rw-r--r-- | libavformat/segment.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c index 2b1ad0ece8..bb92fc235d 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -37,6 +37,7 @@ #include "libavutil/mathematics.h" typedef enum { + LIST_TYPE_UNDEFINED = -1, LIST_TYPE_FLAT = 0, LIST_TYPE_EXT, LIST_TYPE_M3U8, @@ -282,9 +283,15 @@ static int seg_write_header(AVFormatContext *s) if (!oc) return AVERROR(ENOMEM); - if (seg->list) + if (seg->list) { + if (seg->list_type == LIST_TYPE_UNDEFINED) { + if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT; + else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8; + else seg->list_type = LIST_TYPE_FLAT; + } if ((ret = segment_list_open(s)) < 0) goto fail; + } for (i = 0; i< s->nb_streams; i++) seg->has_video += @@ -411,7 +418,7 @@ static const AVOption options[] = { { "segment_format", "set container format used for the segments", OFFSET(format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, { "segment_list", "set the segment list filename", OFFSET(list), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, { "segment_list_size", "set the maximum number of playlist entries", OFFSET(list_size), AV_OPT_TYPE_INT, {.dbl = 5}, 0, INT_MAX, E }, - { "segment_list_type", "set the segment list type", OFFSET(list_type), AV_OPT_TYPE_INT, {.dbl = LIST_TYPE_FLAT}, 0, LIST_TYPE_NB-1, E, "list_type" }, + { "segment_list_type", "set the segment list type", OFFSET(list_type), AV_OPT_TYPE_INT, {.dbl = LIST_TYPE_UNDEFINED}, -1, LIST_TYPE_NB-1, E, "list_type" }, { "flat", "flat format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_FLAT }, INT_MIN, INT_MAX, 0, "list_type" }, { "ext", "extended format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_EXT }, INT_MIN, INT_MAX, 0, "list_type" }, { "m3u8", "M3U8 format", 0, AV_OPT_TYPE_CONST, {.dbl=LIST_TYPE_M3U8 }, INT_MIN, INT_MAX, 0, "list_type" }, |