[FFmpeg-devel] [PATCH] lavf/segment: add M3U8 list support
Stefano Sabatini
stefasab at gmail.com
Wed Aug 15 23:50:30 CEST 2012
On date Wednesday 2012-08-15 17:12:30 +0200, Clément Bœsch encoded:
> 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?
I believe we adopt UTF-8 for specifying filenames if I'm not wrong,
and sure we don't use non-ASCII chars in the tags.
> 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.
I extended the docs specifying that we support the thing people call
"Extended M3U8", "flat" format should be equivalent to "plain" M3U8
lists.
>
> > 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)?
No.
> Because in that case, IIRC the spec require to get the higher value.
From:
http://tools.ietf.org/html/draft-pantos-http-live-streaming-07#section-3.3.2
|The EXT-X-TARGETDURATION tag specifies the maximum media segment
|duration. The EXTINF duration of each media segment in the Playlist
|file MUST be less than or equal to the target duration. This tag
|MUST appear once in the Playlist file. It applies to the entire
|Playlist file. Its format is:
|
|#EXT-X-TARGETDURATION:<s>
|
|where s is an integer indicating the target duration in seconds.
I'm putting the EXT-X-TARGETDURATION at the end of the file, which is
not forbidden by the specification.
>
> > + }
> > + 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.
This is unrelated with the current patch, would you mind send a patch
for that?
Patch updated (on top of the previously posted patches).
--
FFmpeg = Fiendish and Frenzy Majestic Perennial Esoteric Gem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-lavf-segment-add-M3U8-list-support.patch
Type: text/x-diff
Size: 3754 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120815/e5ee382f/attachment.bin>
More information about the ffmpeg-devel
mailing list