Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Lucy" <lucy@absolucy.moe>
To: <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: Use HLS version 2 if rounded durations are enabled
Date: Sun, 26 Jun 2022 21:11:52 -0400
Message-ID: <003901d889c2$f4236250$dc6a26f0$@absolucy.moe> (raw)

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".

             reply	other threads:[~2022-06-27  1:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27  1:11 Lucy [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003901d889c2$f4236250$dc6a26f0$@absolucy.moe' \
    --to=lucy@absolucy.moe \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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