From patchwork Mon Jun 27 01:11:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucy X-Patchwork-Id: 36481 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp1727075pzh; Sun, 26 Jun 2022 18:12:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tiqZtQBchFd6SdtFyTUyDLR++n4TX6ZTsmRZe7w2ZyDVuj2K+dycIiGiajsOqN7dEKHZxn X-Received: by 2002:a17:906:a219:b0:6e4:86a3:44ea with SMTP id r25-20020a170906a21900b006e486a344eamr10666983ejy.385.1656292363579; Sun, 26 Jun 2022 18:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656292363; cv=none; d=google.com; s=arc-20160816; b=Fs8HSzfteX/c3OddxolZtg70ZWyOf9Is00+WkgouzQHEtQzCEvTal428jZX8Ty4kcs NiwKa3BpJKqTej5HNV+ND4Ze0Et0lafA/qRS7pVJMP3+UgWx3u6QiX3BJLYlMclejSOp jvQBgSkyccL9LNbRzXu3BTwFIKfWmnYRM0CnjFrKz6sPppfXbvWuyRk54uPGJcEvwhvC LS+KqxP7zAJWUepHpd58qqToCFet6B2xiySCYJcSYMSHm1CeY8aVXJFH79+FVhSXmnTx Oasweo+3nQcplXQKpNgYvda1j+2fExn8npNQHNCQWoytGtbNXI4YRDRaKpVGaDg+TFgd YDeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:thread-index:mime-version :message-id:date:to:from:dkim-signature:delivered-to; bh=6qSFBzvTAu+c65GSsRQrJE9t78KhqFD4paPCWVmA8Xs=; b=OMT05nHGNqJD6qyaiIMa4gv8/EZjW3yhMLXU8S65jEtRGoGeRf62yT1afu7egb6Y+S whCMNQuRjgXf5xaq7UuVtYi1DgdHi/h9sKS/eMS1P3zqwb/HiELWdV/FTlev/jqqWpgA t+nJSIah0pEF8mt4JMo3l0KxlJAbSmghMkou09u+UH4Zo2lPFuN2cRYVw0IE+6yObCa4 ViDmGHjD4GweZ9ZyPXS9LZCXVL4zXg6hQIbxhGcLH4Gdz2hjoZ89fWZ6QZkKwriG2KJb NPlnkNywlivNrz0q+/S1cBF10cYTAHIyZeSE3uXCmpyTOa4F5BbsTzoG868S8c6W5j6n sTDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@absolucy.moe header.s=x header.b=u8OlKk0H; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=absolucy.moe Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ht16-20020a170907609000b0071579ac7f1csi10083011ejc.523.2022.06.26.18.12.42; Sun, 26 Jun 2022 18:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@absolucy.moe header.s=x header.b=u8OlKk0H; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=absolucy.moe Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07D8068B85A; Mon, 27 Jun 2022 04:12:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-108-mta84.mxroute.com (mail-108-mta84.mxroute.com [136.175.108.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D77D668B830 for ; Mon, 27 Jun 2022 04:12:31 +0300 (EEST) Received: from filter006.mxroute.com ([140.82.40.27] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta84.mxroute.com (ZoneMTA) with ESMTPSA id 181a2b785b200095ec.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Mon, 27 Jun 2022 01:12:25 +0000 X-Zone-Loop: bf35194bb8ea54aeeaf3a74ce8944e3fbe2eedc6d78b X-Originating-IP: [140.82.40.27] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=absolucy.moe; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version: Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XVcECg/ZMb1YRhqxoqM8dMGDcdJVC9pxib56Q0ZyB40=; b=u8OlKk0HeNex5k/xWS4NSEgw2b 2P9j583aD6naGV8VpQPciG7fNCnnRLvi7b4TRuiDs+2IMHGAh4+HG3d3DMAfb7M/RrIVU/vpSFSHx zh8bTjTnwmy7ZwO/25BZZxkL0TrLl/dYPBKPaR0zBdQ+DbrTrGS9rONhl1l6h7wAjt94dglddjfVt JZDX4asTaidsDYIx62lKuGUxfNJjNZ0Q0LuB1aamQTehr5XowEPRv9Bm6mJgILPbsx4XtwQTmoRTy 4GK5VJHiBPDRMY1SCmmuPRQWesrrQudoYYkkHMXuNJvwriRlNgImiPfzgC5LKtqYObZ36RYGYX8/r QMvIadPQ==; From: "Lucy" To: Date: Sun, 26 Jun 2022 21:11:52 -0400 Message-ID: <003901d889c2$f4236250$dc6a26f0$@absolucy.moe> MIME-Version: 1.0 Thread-Index: AdiJsuUzXanEmemRROy6dyzAp0EiGQ== Content-Language: en-us X-AuthUser: lucy@absolucy.moe Subject: [FFmpeg-devel] [PATCH] avformat/hlsenc: Use HLS version 2 if rounded durations are enabled X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bH1NM6C9f9pY 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 --- doc/muxers.texi | 2 ++ libavformat/hlsenc.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) if (byterange_mode) { hls->version = 4; sequence = 0; 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; + } +