[FFmpeg-devel] [PATCH] lavf/segment: guess list type from list filename suffix

Clément Bœsch ubitux at gmail.com
Sat Aug 18 11:35:05 CEST 2012


On Thu, Aug 16, 2012 at 12:18:15AM +0200, Stefano Sabatini wrote:
> FIXME: bump micro
> ---
>  doc/muxers.texi       |   10 +++++++---
>  libavformat/segment.c |   11 +++++++++--
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index c30d1cd..ece4452 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -433,8 +433,9 @@ time.
>  
>  The segment muxer works best with a single constant frame rate video.
>  
> -Optionally it can generate a flat list of the created segments, one segment
> -per line, by setting the option @var{segment_list}.
> +Optionally it can generate a list of the created segments, by setting
> +the option @var{segment_list}. The list type is specified by the
> + at var{segment_list_type} option.
>  
>  The segment muxer supports the following options:
>  
> @@ -470,12 +471,15 @@ muxer according to the provided pattern, and should not contain the
>  @var{segment_start_time} and @var{segment_end_time} specify
>  the segment start and end time expressed in seconds.
>  
> +A list file with suffix @code{".ext"} will auto-select this format.

with *the*?

>  @item m3u8
>  Generate an extended M3U8 file, version 4, compliant with
>  @url{http://tools.ietf.org/id/draft-pantos-http-live-streaming-07.txt}.
> +
> +A list file with suffix @code{".m3u8"} will auto-select this format.
>  @end table
>  
> -Default value is "flat".
> +If not specified the type is guessed from the list file name suffix.
>  @item segment_time @var{time}
>  Set segment duration to @var{time}. Default value is "2".
>  @item segment_time_delta @var{delta}
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 29c053b..1a0b7d5 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,
> @@ -283,9 +284,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 +=
> @@ -412,7 +419,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" },

LGTM, good idea.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120818/62e879c7/attachment.asc>


More information about the ffmpeg-devel mailing list