You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/hlsenc: Add hls flag for rounding m3u8 durations to whole numbers, problems with floats on some devices
Reviewed-by: Thomas Volkert <silvo@gmx.net>
This commit is contained in:
committed by
Michael Niedermayer
parent
b6fcb2bb6d
commit
8fd01b4a79
@@ -50,6 +50,7 @@ typedef enum HLSFlags {
|
|||||||
// Generate a single media file and use byte ranges in the playlist.
|
// Generate a single media file and use byte ranges in the playlist.
|
||||||
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),
|
||||||
} HLSFlags;
|
} HLSFlags;
|
||||||
|
|
||||||
typedef struct HLSContext {
|
typedef struct HLSContext {
|
||||||
@@ -274,6 +275,9 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
sequence);
|
sequence);
|
||||||
|
|
||||||
for (en = hls->segments; en; en = en->next) {
|
for (en = hls->segments; en; en = en->next) {
|
||||||
|
if (hls->flags & HLS_ROUND_DURATIONS)
|
||||||
|
avio_printf(out, "#EXTINF:%d,\n", (int)round(en->duration));
|
||||||
|
else
|
||||||
avio_printf(out, "#EXTINF:%f,\n", en->duration);
|
avio_printf(out, "#EXTINF:%f,\n", en->duration);
|
||||||
if (hls->flags & HLS_SINGLE_FILE)
|
if (hls->flags & HLS_SINGLE_FILE)
|
||||||
avio_printf(out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n",
|
avio_printf(out, "#EXT-X-BYTERANGE:%"PRIi64"@%"PRIi64"\n",
|
||||||
@@ -512,6 +516,8 @@ static const AVOption options[] = {
|
|||||||
{"hls_flags", "set flags affecting HLS playlist and media file generation", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX, E, "flags"},
|
{"hls_flags", "set flags affecting HLS playlist and media file generation", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 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"},
|
{"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"},
|
||||||
|
|
||||||
|
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user