From patchwork Mon May 15 00:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41607 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1222911pzb; Sun, 14 May 2023 17:06:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Obt7WH28aPHzumq7d/7mrX9i3ZyufJcrlrw1s6Nxmw3Xml5ZdQ2oi/d9AzkFfZA8JLpGd X-Received: by 2002:a17:907:360c:b0:961:800b:3f1e with SMTP id bk12-20020a170907360c00b00961800b3f1emr30439872ejc.73.1684109160368; Sun, 14 May 2023 17:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684109160; cv=none; d=google.com; s=arc-20160816; b=ietph8kviuzYITIwe/YlvhpncAF2Tasa/u5CjzEPPZEi/O+JgjEUBzaUXCYyGfCJcd QwZa6o/eD80Ow61bHGRDqsBMaw6HwU5/Q7eT4UI/7blXZh6kvyR/zqi40GOLqlSZBSRp TP/T70/rvC12ILWgGpCzP4679wQoJLY9hpvKrTMlBDwjuEzKwtkJXMRhYWzsnCe4t2eK cnXAsIj3j0d2okKvQQ6gtPVqb58dhI7RK1chn3syzkLcxq5zqOZEaRFyjXSufSNhHAEr bgM+1jhHBfWLhZa9XE0JTVbXsAFeHqkz4Qtl4R0InO7Q5+gST4PN7AKVg23dDVKYSpPE M4hg== 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:mime-version:message-id:date:to:from :delivered-to; bh=D62/vGXus0jiCFO19gX+QXLPSU8wBpsIOsrQ3TKb4w0=; b=UZU/dULUh0Oo0AT8BmYGtLRLAiPNKIQ4T04k2Zvx8j1ehx2RLo9AHiDqjgZ84l/P38 U65Mu//kshmNErqekjQNa/ZTbCk+9v5fkRjyvINGhHSYpE7RBwPy0MF0r53Qm4nDmCv1 htSo0bF+G0VF6wLne3f1R+iMzc24y6yW52Ye6kfndZb+UdUf5K+QPLJVVuT53ez1PvEO iX9VAlCxb5r+JB/GX3HA757vTyoRYaLichHFbYNvTcgBQz9+N3LOmcHqOA72QtEUTaYq tYK+Ie2XKAHJATDi7h/B3QFDiP9QiolSotXQZgSNoPC18P9pEEolFZpogaPZL2wIBCDc oR/g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d20-20020a170906371400b00959af644ac4si10928422ejc.761.2023.05.14.17.05.59; Sun, 14 May 2023 17:06:00 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E212968BFC8; Mon, 15 May 2023 03:05:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D2A368AFCE for ; Mon, 15 May 2023 03:05:49 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id A743CC0002 for ; Mon, 15 May 2023 00:05:48 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 15 May 2023 02:05:45 +0200 Message-Id: <20230515000547.1703-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/hls: reduce default max reload to 3 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: yS51/ibq4Ohm The 1000 did result in the appearance of a never ending reload loop The RFC mandates that "If the client reloads a Playlist file and finds that it has not changed, then it MUST wait for a period of one-half the target duration before retrying." and if it has changed "the client MUST wait for at least the target duration before attempting to reload the Playlist file again" Trying to reload 3 times seems a better default than 1000 given these durations Issue found by: Сергей Колесников Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 11e345b280..df2442c376 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2556,7 +2556,7 @@ static const AVOption hls_options[] = { {.str = "3gp,aac,avi,ac3,eac3,flac,mkv,m3u8,m4a,m4s,m4v,mpg,mov,mp2,mp3,mp4,mpeg,mpegts,ogg,ogv,oga,ts,vob,wav"}, INT_MIN, INT_MAX, FLAGS}, {"max_reload", "Maximum number of times a insufficient list is attempted to be reloaded", - OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, + OFFSET(max_reload), AV_OPT_TYPE_INT, {.i64 = 3}, 0, INT_MAX, FLAGS}, {"m3u8_hold_counters", "The maximum number of times to load m3u8 when it refreshes without new segments", OFFSET(m3u8_hold_counters), AV_OPT_TYPE_INT, {.i64 = 1000}, 0, INT_MAX, FLAGS}, {"http_persistent", "Use persistent HTTP connections", From patchwork Mon May 15 00:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41608 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1222996pzb; Sun, 14 May 2023 17:06:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66ZXtCob11vkuGxOINvmkqvWuH+s4ExeRSbhGdU7yExR4pb9ts3Pel9wBEjfYuZ2lyofGK X-Received: by 2002:a05:6402:1016:b0:50d:f9b1:6918 with SMTP id c22-20020a056402101600b0050df9b16918mr8085898edu.9.1684109170209; Sun, 14 May 2023 17:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684109170; cv=none; d=google.com; s=arc-20160816; b=bok9xsJph5S4amLPDcu+bwmwQkt0tbY57V6QUS5s4v8xo12tvl0Qrc2NGDNVmJwxXH l2LaZo8MfFbST2/J4JfmtTE26EL8vpa/TNctK+IfFwKWSi6z5tE3UliZUXQwEiBuy4VU DLIQtjwuYFUZramURRbXU6hsZ6TK16gSlysvpoD+/rUc0gdB34Ez95EmjojXnUNbCg5G Bf2CORzK785pN66YvAEnmP2SS9l+yMDM9uyc6IaMVJ7BfSiFaaHfvHfUC+8+fB1NEco3 2/Zi3V0seZDVT/lG0nvDnUNlE+O9oRycuAOyC6DvxageGi+uPjAiot7caUbeKx7q7ggu 6stg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=EJ8lsGBwQHnFci5JzdgRH9aoKHqHvOULbtZNdKLXHnU=; b=FbpcSra+Ke+pQ+qKyPVEMEB09BtYtF8SuQB1JyTMP62hp402zzsHDGRU0hp381pMXJ B1T3spH7q8/areQvm1gEdaeMns6UL6NbhZJhYiNR/s9pkacgslg3PnwegApS+OC6K7Bo uNbE8wqD0z4YB5HegTZ5uHM/SysSOBcTwRqqiX1iQVkFJN9h1dbZYi8J2RffbRPa+5Xf QciQwebOrfwMuLB2ktpunNCGhLfcO4C2cdI02v+jD8eTEdtJ4ktOi3bM33Lo8qfu+EF+ ONvVPl7nyS1raxbwqNAI7CwakPW1iGzz5GJ2NftklbB7qxmEJ+F1Z0xJVHQdFgqtiQMb TlMw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g10-20020a50ee0a000000b0050bfbf8fa01si11490788eds.73.2023.05.14.17.06.09; Sun, 14 May 2023 17:06:10 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E8B9E68B75C; Mon, 15 May 2023 03:05:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B3C268BF40 for ; Mon, 15 May 2023 03:05:50 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 85B7D1BF203 for ; Mon, 15 May 2023 00:05:49 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 15 May 2023 02:05:46 +0200 Message-Id: <20230515000547.1703-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230515000547.1703-1-michael@niedermayer.cc> References: <20230515000547.1703-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/3] avformat: add ff_match_url_ext() 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: BmQ1ZRGbzfqI Match url against a list of extensions similar to av_match_ext() Signed-off-by: Michael Niedermayer --- libavformat/format.c | 25 +++++++++++++++++++++++++ libavformat/internal.h | 9 +++++++++ 2 files changed, 34 insertions(+) diff --git a/libavformat/format.c b/libavformat/format.c index 52b814e67d..04fdbacec0 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -50,6 +50,31 @@ int av_match_ext(const char *filename, const char *extensions) return 0; } +int ff_match_url_ext(const char *url, const char *extensions) +{ + const char *ext; + URLComponents uc; + int ret; + char scratchpad[128]; + + if (!url) + return 0; + + ret = ff_url_decompose(&uc, url, NULL); + if (ret < 0 || !URL_COMPONENT_HAVE(uc, scheme)) + return ret; + for (ext = uc.query; *ext != '.' && ext > uc.path; ext--) + ; + + if (*ext != '.') + return 0; + if (uc.query - ext > sizeof(scratchpad)) + return AVERROR(ENOMEM); //not enough memory in our scratchpad + av_strlcpy(scratchpad, ext + 1, FFMIN(sizeof(scratchpad), uc.query - ext)); + + return av_match_name(scratchpad, extensions); +} + const AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { diff --git a/libavformat/internal.h b/libavformat/internal.h index f575064e8f..43466fbe6d 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -705,6 +705,15 @@ int ff_unlock_avformat(void); */ void ff_format_set_url(AVFormatContext *s, char *url); +/** + * Return a positive value if the given url has one of the given + * extensions, 0 otherwise. + * + * @param filename file name to check against the given extensions + * @param extensions a comma-separated list of filename extensions + */ +int ff_match_url_ext(const char *url, const char *extensions); + struct FFOutputFormat; void avpriv_register_devices(const struct FFOutputFormat * const o[], const AVInputFormat * const i[]); From patchwork Mon May 15 00:05:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41609 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:ba91:b0:105:feb:71f2 with SMTP id fb17csp1223060pzb; Sun, 14 May 2023 17:06:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LkfPN3cg1UhSNOFhj/181nurmDqAVR+3G14eVAYuZdlZvCNThnoWDndmtfYcQaR+Sss4x X-Received: by 2002:a17:907:608e:b0:96a:c15b:2b83 with SMTP id ht14-20020a170907608e00b0096ac15b2b83mr8008251ejc.54.1684109179425; Sun, 14 May 2023 17:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684109179; cv=none; d=google.com; s=arc-20160816; b=F9B5Q7Zm9J7QZ2Vi9DztQueYSoUDw149Uw8frAUJ7iMA4LSKML4e0UKetFmrOx7dAQ jqclgXF9K55rfr6RY2LJXbbvB292fAViUbejNN2iGUzuOWkzAl/XlekZcAH+Q3pmlS63 78jBaOu16ANRbrUgE6HC1KcidG12Wrcr+d5ervs/vUZ4nm8Y3C5LKTYUrXOjYEVWaXJP VSUBbvYaL8TEQpJYNG3+iNFP5L1tTaL0LWNYLpCO2zZH3cJBhocyCEZdiLdsBXtNQGDS 1KPhaiX3Gl7OdUldB+XJ+1QFphBReTUCCScntXwF2KYkUaBxHYQHikB9WB6/EObUM+4r wtwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=sIzN8e46YM2HAtThE2CBLsPkpjCA4LbNHQ3z96U6ZT8=; b=qaSEoa/UDXz8BTrl0AqaQwbPx8n3WUHC79NXwfTjbQc0MyfDO14N44n8lmr5H042g8 mnaiDfoqhsGhNIQnhsG5VJ+zuhkmAnLPY5Eb9fIrNkvesBWduQel0bJI7TEofHJUipZw DtIjqkbtzXfzDbERuiWJ/RJntOwytPaVTUnhLLkSkaqddK0kzBpLqOfxTE0IVBTz5IRJ T9u6Pj7qu3ZVIfEI2ve6cUAC8TBlx1zkdpJSywjtHYomy0UVrOV++28PBoDQJ/NZuxFP bmwzXP+9CnlKqZFsrSzYBwoNUv6Ty0V41VYSWnPLonK68D94EfA+Ey6s2nZP1EaJaISq fvGA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id vr14-20020a170907a50e00b009682bb2aa14si12236014ejc.32.2023.05.14.17.06.19; Sun, 14 May 2023 17:06:19 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0748368BFE7; Mon, 15 May 2023 03:06:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D576968BFC1 for ; Mon, 15 May 2023 03:05:50 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 47D211BF209 for ; Mon, 15 May 2023 00:05:50 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 15 May 2023 02:05:47 +0200 Message-Id: <20230515000547.1703-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230515000547.1703-1-michael@niedermayer.cc> References: <20230515000547.1703-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avformat/hls: Try to implement RFC8216 playlist refusal 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: AjNnpXf1IYHg This is not well tested and can likely be improved, just a hotfix for hls probe failures since 6b1f68ccb04d791f0250e05687c346a99ff47ea1 Should fix Ticket10353 (please test and report cases that still fail) Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index df2442c376..790ae7a96a 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2534,7 +2534,16 @@ static int hls_probe(const AVProbeData *p) strstr(p->buf, "#EXT-X-TARGETDURATION:") || strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:")) { - if (!av_match_ext(p->filename, "m3u8,hls,m3u")) { + int mime_ok = p->mime_type && !( + av_strcasecmp(p->mime_type, "application/vnd.apple.mpegurl") && + av_strcasecmp(p->mime_type, "audio/mpegurl") && + av_strcasecmp(p->mime_type, "audio/x-mpegurl") && + av_strcasecmp(p->mime_type, "application/x-mpegurl") + ); + + if (!av_match_ext (p->filename, "m3u8,hls,m3u") && + ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0 && + !mime_ok) { av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non standard extension\n"); return 0; }