[FFmpeg-devel] [PATCH] lavf/segment: add M3U8 list support

Clément Bœsch ubitux at gmail.com
Wed Aug 15 17:12:30 CEST 2012


On Wed, Aug 15, 2012 at 11:09:59AM +0200, Stefano Sabatini wrote:
> Address trac ticket #1642.
> ---
>  libavformat/segment.c |   24 +++++++++++++++++++++++-
>  1 files changed, 23 insertions(+), 1 deletions(-)
> 
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 744c147..35363b5 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -34,6 +34,7 @@
>  typedef enum {
>      LIST_TYPE_FLAT = 0,
>      LIST_TYPE_EXT,
> +    LIST_TYPE_M3U8,

The 8 means it will honor properly UTF-8, I guess that will be true?

Also, that current M3U8 implementation is an extended version of the M3U
format, so I'm not so sure about the name. Since it's not documented, I'm
not sure that's really important though.

>      LIST_TYPE_NB,
>  } ListType;
>  
> @@ -119,6 +120,10 @@ static int segment_end(AVFormatContext *s)
>  
>      if (seg->list) {
>          if (seg->list_size && !(seg->number % seg->list_size)) {
> +            if (seg->list_type == LIST_TYPE_M3U8) {
> +                avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
> +                avio_flush(seg->list_pb);
> +            }
>              avio_close(seg->list_pb);
>              if ((ret = avio_open2(&seg->list_pb, seg->list, AVIO_FLAG_WRITE,
>                                    &s->interrupt_callback, NULL)) < 0)
> @@ -129,7 +134,17 @@ static int segment_end(AVFormatContext *s)
>              avio_printf(seg->list_pb, "%s\n", oc->filename);
>          } else if (seg->list_type == LIST_TYPE_EXT) {
>              avio_printf(seg->list_pb, "%s,%f,%f\n", oc->filename, seg->start_time, seg->end_time);
> +        } else if (seg->list_type == LIST_TYPE_M3U8) {
> +            if (seg->number == 1) {
> +                avio_printf(seg->list_pb, "#EXTM3U\n");
> +                if (seg->time_str)
> +                    avio_printf(seg->list_pb, "#EXT-X-TARGETDURATION:%f\n",
> +                                (double)seg->time/1000000);

Are we sure the target duration won't ever be inferior to one of the
segment duration (because of some approximation or other parameter)?
Because in that case, IIRC the spec require to get the higher value.

> +            }
> +            avio_printf(seg->list_pb, "#EXTINF:%f\n%s\n",
> +                        seg->end_time - seg->start_time, oc->filename);

When I was cutting the big buck bunny sample (check in the hls.py patch
for the exact cmd line I was using), the end_time was always the duration
of the whole presentation, so I'm unsure about that. The workaround I used
in the script was a diff with the start_time of the previous event.

[...]

-- 
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/20120815/27d32d03/attachment.asc>


More information about the ffmpeg-devel mailing list