Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/hlsenc: Use HLS version 2 if rounded durations are enabled
@ 2022-06-27  1:11 Lucy
  2022-06-27  2:17 ` Steven Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Lucy @ 2022-06-27  1:11 UTC (permalink / raw)
  To: ffmpeg-devel

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.

This is my first contribution to ffmpeg, so please tell me if I did anything
wrong, and I'll try my best to fix it.

Signed-off-by: Lucy <lucy@absolucy.moe>
---
 doc/muxers.texi      | 2 ++
 libavformat/hlsenc.c | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

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;
-- 
2.36.1


_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-29  4:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-27  1:11 [FFmpeg-devel] [PATCH] avformat/hlsenc: Use HLS version 2 if rounded durations are enabled Lucy
2022-06-27  2:17 ` Steven Liu
2022-06-27  2:27   ` lucy
2022-06-27  2:44     ` Steven Liu
2022-06-29  4:18       ` Steven Liu

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git