[FFmpeg-devel] [PATCH] lavf/hlsenc: add -hls_start_time to emit EXT-X-START:TIME-OFFSET

Aman Gupta ffmpeg at tmm1.net
Sat Sep 10 09:47:41 EEST 2016


From: Aman Gupta <aman at 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.
 
+ at 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},
-- 
2.8.1



More information about the ffmpeg-devel mailing list