Message ID | 1473490061-12965-1-git-send-email-ffmpeg@tmm1.net |
---|---|
State | Changes Requested |
Headers | show |
2016-09-10 14:47 GMT+08:00 Aman Gupta <ffmpeg@tmm1.net>: > From: Aman Gupta <aman@tmm1.net> > > --- > doc/muxers.texi | 3 +++ > libavformat/hlsenc.c | 5 +++++ > 2 files changed, 8 insertions(+) > > diff --git a/doc/muxers.texi b/doc/muxers.texi > index ccf8ea1..e179c5a 100644 > --- a/doc/muxers.texi > +++ b/doc/muxers.texi > @@ -533,6 +533,9 @@ Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 > header. Forces > Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces > @option{hls_list_size} to 0; the playlist must not change. > > +@item hls_start_time @var{offset} > +Emit @code{#EXT-X-START:TIME-OFFSET} in the m3u8 header. > + > @item method > Use the given HTTP method to create the hls files. > @example > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index a376312..1344613d 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -79,6 +79,7 @@ typedef struct HLSContext { > unsigned number; > int64_t sequence; > int64_t start_sequence; > + float start_offset; > AVOutputFormat *oformat; > AVOutputFormat *vtt_oformat; > > @@ -511,6 +512,9 @@ static int hls_window(AVFormatContext *s, int last) > } else if (hls->pl_type == PLAYLIST_TYPE_VOD) { > avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n"); > } > + if (hls->start_offset >= 0) { > + avio_printf(out, "#EXT-X-START:TIME-OFFSET=%f\n", > hls->start_offset); > + } > the spec said: 4.3.5.2 <https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-4.3.5.2>. EXT-X-START The EXT-X-START tag indicates a preferred point at which to start playing a Playlist. By default, clients SHOULD start playback at this point when beginning a playback session. This tag is OPTIONAL. Its format is: #EXT-X-START:<attribute-list> The following attributes are defined: TIME-OFFSET The value of TIME-OFFSET is a signed-decimal-floating-point number of seconds. A positive number indicates a time offset from the beginning of the Playlist. A negative number indicates a negative time offset from the end of the last Media Segment in the Playlist. This attribute is REQUIRED. The absolute value of TIME-OFFSET SHOULD NOT be larger than the Playlist duration. If the absolute value of TIME-OFFSET exceeds the duration of the Playlist, it indicates either the end of the Playlist (if positive) or the beginning of the Playlist (if negative). If the Playlist does not contain the EXT-X-ENDLIST tag, the TIME- OFFSET SHOULD NOT be within three target durations of the end of the Playlist file. I think there have some think should be checked: the TIME- OFFSET SHOULD NOT be within three target durations of the end of the Playlist file. > av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", > sequence); > @@ -1013,6 +1017,7 @@ static const AVOption options[] = { > {"hls_list_size", "set maximum number of playlist entries", > OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, > E}, > {"hls_ts_options","set hls mpegts list of options for the container > format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str > = NULL}, 0, 0, E}, > {"hls_vtt_options","set hls vtt list of options for the container > format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, > {.str = NULL}, 0, 0, E}, > + {"hls_start_time", "set EXT-X-START:TIME-OFFSET", > OFFSET(start_offset), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, > E}, > {"hls_wrap", "set number after which the index wraps", > OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E}, > {"hls_allow_cache", "explicitly set whether the client MAY (1) or > MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, > {.i64 = -1}, INT_MIN, INT_MAX, E}, > {"hls_base_url", "url to prepend to each playlist entry", > OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, > -- > 2.8.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
diff --git a/doc/muxers.texi b/doc/muxers.texi index ccf8ea1..e179c5a 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -533,6 +533,9 @@ Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces @option{hls_list_size} to 0; the playlist must not change. +@item hls_start_time @var{offset} +Emit @code{#EXT-X-START:TIME-OFFSET} in the m3u8 header. + @item method Use the given HTTP method to create the hls files. @example diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index a376312..1344613d 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -79,6 +79,7 @@ typedef struct HLSContext { unsigned number; int64_t sequence; int64_t start_sequence; + float start_offset; AVOutputFormat *oformat; AVOutputFormat *vtt_oformat; @@ -511,6 +512,9 @@ static int hls_window(AVFormatContext *s, int last) } else if (hls->pl_type == PLAYLIST_TYPE_VOD) { avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n"); } + if (hls->start_offset >= 0) { + avio_printf(out, "#EXT-X-START:TIME-OFFSET=%f\n", hls->start_offset); + } av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence); @@ -1013,6 +1017,7 @@ static const AVOption options[] = { {"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E}, {"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, {"hls_vtt_options","set hls vtt list of options for the container format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, + {"hls_start_time", "set EXT-X-START:TIME-OFFSET", OFFSET(start_offset), AV_OPT_TYPE_FLOAT, {.dbl = -1}, -1, FLT_MAX, E}, {"hls_wrap", "set number after which the index wraps", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E}, {"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, E}, {"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E},
From: Aman Gupta <aman@tmm1.net> --- doc/muxers.texi | 3 +++ libavformat/hlsenc.c | 5 +++++ 2 files changed, 8 insertions(+)