You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/hlsenc: Add hls flag for starting a playlist with a discontinuity on startup
Reviewed-by: Thomas Volkert <silvo@gmx.net>
This commit is contained in:
committed by
Michael Niedermayer
parent
8fd01b4a79
commit
572a8292cb
@@ -51,6 +51,7 @@ typedef enum HLSFlags {
|
|||||||
HLS_SINGLE_FILE = (1 << 0),
|
HLS_SINGLE_FILE = (1 << 0),
|
||||||
HLS_DELETE_SEGMENTS = (1 << 1),
|
HLS_DELETE_SEGMENTS = (1 << 1),
|
||||||
HLS_ROUND_DURATIONS = (1 << 2),
|
HLS_ROUND_DURATIONS = (1 << 2),
|
||||||
|
HLS_DISCONT_START = (1 << 3),
|
||||||
} HLSFlags;
|
} HLSFlags;
|
||||||
|
|
||||||
typedef struct HLSContext {
|
typedef struct HLSContext {
|
||||||
@@ -77,6 +78,7 @@ typedef struct HLSContext {
|
|||||||
int64_t start_pos; // last segment starting position
|
int64_t start_pos; // last segment starting position
|
||||||
int64_t size; // last segment size
|
int64_t size; // last segment size
|
||||||
int nb_entries;
|
int nb_entries;
|
||||||
|
int discontinuity_set;
|
||||||
|
|
||||||
HLSSegment *segments;
|
HLSSegment *segments;
|
||||||
HLSSegment *last_segment;
|
HLSSegment *last_segment;
|
||||||
@@ -263,6 +265,7 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
target_duration = ceil(en->duration);
|
target_duration = ceil(en->duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hls->discontinuity_set = 0;
|
||||||
avio_printf(out, "#EXTM3U\n");
|
avio_printf(out, "#EXTM3U\n");
|
||||||
avio_printf(out, "#EXT-X-VERSION:%d\n", version);
|
avio_printf(out, "#EXT-X-VERSION:%d\n", version);
|
||||||
if (hls->allowcache == 0 || hls->allowcache == 1) {
|
if (hls->allowcache == 0 || hls->allowcache == 1) {
|
||||||
@@ -273,7 +276,10 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
|
|
||||||
av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
|
av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
|
||||||
sequence);
|
sequence);
|
||||||
|
if((hls->flags & HLS_DISCONT_START) && sequence==hls->start_sequence && hls->discontinuity_set==0 ){
|
||||||
|
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
|
||||||
|
hls->discontinuity_set = 1;
|
||||||
|
}
|
||||||
for (en = hls->segments; en; en = en->next) {
|
for (en = hls->segments; en; en = en->next) {
|
||||||
if (hls->flags & HLS_ROUND_DURATIONS)
|
if (hls->flags & HLS_ROUND_DURATIONS)
|
||||||
avio_printf(out, "#EXTINF:%d,\n", (int)round(en->duration));
|
avio_printf(out, "#EXTINF:%d,\n", (int)round(en->duration));
|
||||||
@@ -517,7 +523,7 @@ static const AVOption options[] = {
|
|||||||
{"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"},
|
{"single_file", "generate a single media file indexed with byte ranges", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_SINGLE_FILE }, 0, UINT_MAX, E, "flags"},
|
||||||
{"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"},
|
{"delete_segments", "delete segment files that are no longer part of the playlist", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DELETE_SEGMENTS }, 0, UINT_MAX, E, "flags"},
|
||||||
{"round_durations", "round durations in m3u8 to whole numbers", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX, E, "flags"},
|
{"round_durations", "round durations in m3u8 to whole numbers", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_ROUND_DURATIONS }, 0, UINT_MAX, E, "flags"},
|
||||||
|
{"discont_start", "start the playlist with a discontinuity tag", 0, AV_OPT_TYPE_CONST, {.i64 = HLS_DISCONT_START }, 0, UINT_MAX, E, "flags"},
|
||||||
|
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user