diff options
author | Lucy <lucy@absolucy.moe> | 2022-06-29 11:43:11 +0800 |
---|---|---|
committer | Steven Liu <lq@chinaffmpeg.org> | 2022-06-29 14:03:32 +0800 |
commit | 1af36982965f91d72bbf41be3e8696a1990265db (patch) | |
tree | 213d3b2fcc3a24185d9b851a53147edf958a6a7a | |
parent | 900424cda97082a0f0a4ed9ae6b081d2cef557d7 (diff) | |
download | ffmpeg-1af36982965f91d72bbf41be3e8696a1990265db.tar.gz |
avformat/hlsenc: Use HLS version 2 if rounded durations are enabled
This allows for wider compatibility with older devices, such as those
running iOS 3. The only difference between HLS version 2 and version 3 is
that version 3 supports non-integer EXTINF values, and as such, we can
default to version 2 if we're using whole-integer EXTINFs anyways, when
`-hls_flags round_durations` is set.
As this code seems to otherwise consistently use the lowest compatible
version, this seems to fit in properly with existing behavior.
Testing confirms with that this patch, HLS output can work all the way back
to iOS 3.
Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
Signed-off-by: Lucy <lucy@absolucy.moe>
-rw-r--r-- | doc/muxers.texi | 2 | ||||
-rw-r--r-- | libavformat/hlsenc.c | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/doc/muxers.texi b/doc/muxers.texi index b6cafaa5fd..b2f4326aae 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1060,6 +1060,8 @@ and remove the @code{#EXT-X-ENDLIST} from the old segment list. @item round_durations Round the duration info in the playlist file segment info to integer values, instead of using floating point. +If there are no other features requiring higher HLS versions be used, +then this will allow ffmpeg to output a HLS version 2 m3u8. @item discont_start Add the @code{#EXT-X-DISCONTINUITY} tag to the playlist, before the diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 3bafddfa61..7c097b4bf2 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1550,7 +1550,11 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs) double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? &prog_date_time : NULL; int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0); - hls->version = 3; + hls->version = 2; + if (!(hls->flags & HLS_ROUND_DURATIONS)) { + hls->version = 3; + } + if (byterange_mode) { hls->version = 4; sequence = 0; |