From patchwork Mon Jun 24 08:49:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 50115 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp1867352vqz; Mon, 24 Jun 2024 01:49:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW94gydjC6p7VplKZwkSryDRfRwY6WWyve6ZHUofAINkP5OIEy4t6NH2J/7iY74UDPWbUxaAXZroFRssWTko90EGJWNCmhQ+3VCUw== X-Google-Smtp-Source: AGHT+IGpwuH8fJHQ4rTFZFtTaZAJ5jPSl4+9MQFLSOtVNn2q3yBA0TwMFQ3JoqjEyI+U7pw4HRkL X-Received: by 2002:a17:907:780c:b0:a6e:d339:c09c with SMTP id a640c23a62f3a-a7245c80b5bmr299318066b.48.1719218997573; Mon, 24 Jun 2024 01:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719218997; cv=none; d=google.com; s=arc-20160816; b=qJp1VLqXDae/9XG6Cf0PzpX0SNSAlSC8XOS8JzhDyA5Tlpf1lGLfmXOzHzMJI58hpZ W5BDkNaUGxVFOyXWqaMaAyJWFGTawKhFqFV21t75tkvmHPdbHbiTP/Gm6OAA842F1ZEw uZj6IVyJMQteNEHkhxv3mt9lrOWI57y/YgGIXa/phALgSgLZAScPLN45EboWswUoq0Op 8l+Xu/IXvH7SKKApnP+brqkfltRAwEf20+F8nRyhlr9FPzvbDYW7g83cMk9yB5FHEmB0 43xho6M6MZwRQf4Wym7zkwmikzl2dksK0UcRQO1hXtueprblZsxEfTOMRPsIuwFJWZNp KF1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=SjKt+6AJIKmIqyfNVcCqz7FSm7Wn2/HYCxqVgVy/eao=; fh=UvIsH30fhBXMmPtaePKJMeMspabJNvEuvy3Hi3mTDRo=; b=Lu+rXLLzQhoxRlRbYT2YR6eVTOb8Bly+01+EwkwvPaPTSDi3eTtI46a+G8PCh22Hdv TSlQD0y2gu2JZuseSzqyf0DSwiZewlDkKa1sn/bv1oPRJP8cr081g50Vv7Yoc6/U0GcX hiv8UhR2X/XM+6ZCV/rDE57kzzllKi2JClNXA/Reqeysg/fCu5Zfqxup8aQYQAjZeu9t 8p+LnuusToIrZcL5HOX/ImkVr3zw+m77Fl7eOTv71nWnip2MXpLBjFP84D9gx2pXPOqM GgH9P42OvcmLHmQe9VlLaG6OGwkAyp31lRycFzox985pvrIHrYWQ7HeiUAcYOgGhKDI2 9GJg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=Ah85eOZ5; 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 a640c23a62f3a-a6fcf579ccdsi346581766b.848.2024.06.24.01.49.57; Mon, 24 Jun 2024 01:49:57 -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=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=Ah85eOZ5; 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 6511268C0EB; Mon, 24 Jun 2024 11:49:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C765F68C0EB for ; Mon, 24 Jun 2024 11:49:45 +0300 (EEST) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-52cdd893e5cso1875624e87.1 for ; Mon, 24 Jun 2024 01:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1719218985; x=1719823785; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w/JmEiku+UenKdtOzTbEM9LeDwd2twhQbA4B89VTa/Q=; b=Ah85eOZ5raW1x4ebHdE7BH/YV5pk6Gg+EnioZqXai2uOdFRcilOOyO0shfQUWXNAo2 Lg/JOlA0tDC9AIa4OVmu2aclREWLKDVH5p/lKfaNkDED6I6Of3hj1nF9lbLCKRwgTxPI Q2sdjpA0Z5sT2RFM4kJcvPWofb9Hmb4tTDxf2lOHIKm1oKCX/3Bt4a2o7y3t4Pe6HKzo CSV9w/gTvcl7dhSMXFp2+XcRdyaAmmbRn4rOoQTdjdp3sXq90w1oZ41CusMTdrCQVvyC vbupkPQmAy69MXc17Z+ukWMqUhrwcrfGE09TLkUAU9FDyt99REmoS3xDKg+eJeNdahvf nFng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719218985; x=1719823785; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w/JmEiku+UenKdtOzTbEM9LeDwd2twhQbA4B89VTa/Q=; b=KGBo1+mdvj5qs1abv28ybkAVfIwJk0+0Ly8MNbfaKIGRfJc8U1HQaR2eqAnBqoqPQy A6k7sv8prJ5StHjS8yWfnR24xmtRQc/VGD/8MgEutlF4Ac9/HXjy/vVAZM4vl/Q+Cl0i ICTuO2Wefw6pwDkEwHKp81/Cu3ynMp47Q41LAVSLh9jOTek241hCuxbgXOiMmP5Li6d1 FWWO4vhR0MzNg14hRpu3WrqjyumrBtvFU8Xj2yC2XDJEPxGK3wdIZlbBaa19uRU+nHSV Oc3JadOtYDvOeKKHBx30cLcrRDy/S1jHSr0c0YVROvpEH+9VM/RC01Jc7sT5hpnzm3bL YCMA== X-Gm-Message-State: AOJu0Yw43X6QVBUwB7wyzATs4T5+c794eqRAm4WOQ2EeNo2i6NXOGUCd 5TWCYPKQ89UP5vIe3Ef/HzfmL9Q5oMTBqWpPu9Ah5XNbqfqgU3na1+bklaeC001iKXAt89Vlr0N xzg== X-Received: by 2002:ac2:4c86:0:b0:52c:d27b:ddcb with SMTP id 2adb3069b0e04-52ce183270emr2756957e87.3.1719218984852; Mon, 24 Jun 2024 01:49:44 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd63cd109sm937773e87.116.2024.06.24.01.49.44 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2024 01:49:44 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jun 2024 11:49:41 +0300 Message-Id: <20240624084944.14276-1-martin@martin.st> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] hlsenc: Fix the return value accumulation in append_single_file 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 Cc: lq@chinaffmpeg.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 03pLfj3AmKRU Both the read_byte variable (which is accumulated into append_single_file) and the return value are int64_t; give the ret variable the right corresponding type too. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index f5c0243cf1..3d5eb47e84 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2380,7 +2380,7 @@ static int hls_init_file_resend(AVFormatContext *s, VariantStream *vs) static int64_t append_single_file(AVFormatContext *s, VariantStream *vs) { - int ret = 0; + int64_t ret = 0; int64_t read_byte = 0; int64_t total_size = 0; char *filename = NULL; From patchwork Mon Jun 24 08:49:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 50116 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp1867439vqz; Mon, 24 Jun 2024 01:50:09 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVj1NGQ6CxfbyB4n4ZhXfS2P4DcocVMFBMWxN6GQm6uj4ufTIRcZpiHBDcByf/3K5Mn7V1Ls3wlnRXPdOnjwX1g2nd1NQX3pJVNhg== X-Google-Smtp-Source: AGHT+IFG3xWCXYdFRe7X2rR7C9Z/ZRFUVAYNy9L9kbPopSzQYS23z/Yz6VkleM60j1hfh2cWkS2g X-Received: by 2002:a50:a69d:0:b0:57d:3791:e8e1 with SMTP id 4fb4d7f45d1cf-57d4bde09cemr2657103a12.36.1719219009382; Mon, 24 Jun 2024 01:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719219009; cv=none; d=google.com; s=arc-20160816; b=S4Mo09NQgntNIeWqgDC8P2eI3DKHxsMC/eLsB5pff5a1CGI3M3rYi4hUnlg1FqxASt 8oGMOqjJa8u+Z4/GgD2wPUPenoBXAcPD7JEvQkBHu5gfQ4mdgIV3ZF/RV7BqYnke/54l HeKAdfPKwtmaXBgQr3ZGYrRzrYU9CmCmf4A3n67/wgGLskTQFRXjQ6faf8zM/wswwn3I +ZMeKZebD5waYasM/2cKuydm0nUuvmddhfhSoj3Lqtx76PnabXywDEJEZIlC5EHKdXpV tAySBfV5756gNSByPPZhbtQtGlDKQlIk65qLkWtV6hr93EhQVWlPzK96LtRQ3juYvV5k aHfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ikK/Pgn4TpTfhmZF9gWUE/PVCrSOo9/JVaLyOmFMBd0=; fh=UvIsH30fhBXMmPtaePKJMeMspabJNvEuvy3Hi3mTDRo=; b=dYDxHV0cHDHfBaTRA0Ws9BF5eFmr7xhtioZyLWV0YUOAtzUomumnmDnBW+A9FUBlkT Iiy0shaE7Jp+lZMhdrDupVJEHzxQEQzo+nsPFpQwKf0NP9JCmNhjjJRwThAre9hXPX+o evU+TASxIum3xrLd8TlT+rjEdrcXSNcSDEhXbidxSk5bxib5dSNiP/Ist/sG+K2eO4X4 McA7574vJFz3DO9KrnvMqmtf5CR3FeYGaFV4AtYB9qlQqdv96gXu4C0/GY4o14+B0Rtw j/Vmeu7koLXgJ89mQBdrBInhfuxaPR467RhScMktF7zaPuIewng9Mj0I9mlVpN0tkSE7 UmpQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=wd7iSyN4; 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 4fb4d7f45d1cf-57d30632dbasi3579342a12.130.2024.06.24.01.50.08; Mon, 24 Jun 2024 01:50:09 -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=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=wd7iSyN4; 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 A94F768D630; Mon, 24 Jun 2024 11:49:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5024B68C0EB for ; Mon, 24 Jun 2024 11:49:46 +0300 (EEST) Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-52cd8897c73so2723110e87.2 for ; Mon, 24 Jun 2024 01:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1719218985; x=1719823785; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vY/mloxkuJevoJgPsdQohyCFyuLtyKYhXRL2Brwy7WA=; b=wd7iSyN4gP9WSOt1suLaZ+OvnmnuKOY8fehjlTSchMiobOPsKmsc4xS1xXHJjtx5to uaiIVeswLp0HvcCu47YnY0AcEnJoxtboGB6R45D2eGF2lvg8OyLnqhkn+aT85A3XI/6/ CedWbO/rVtlBeXnItivy3zUCb6qTGKI/PAv9wD1zaW1kEvLvSBvD2Ff9G9IZKkHGANvd qMKmoVOIkM8D5bjDa551Mvuec1B3uhb4TChQ4Ij1ogvyE5YY5I4+FBxutGLhqUAIuKQa 8Hf8vFbBTs/YyuqEn/phvwl0MAjWfeqG5lWVhuX1Pt66UUy+8Lp5PlDRoEFumGhY2ttY VIkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719218985; x=1719823785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vY/mloxkuJevoJgPsdQohyCFyuLtyKYhXRL2Brwy7WA=; b=X4j0eig1gZPVLKHYq6PDsbEsItQbGRJ49QVIG4OxCUawdgKETTJcN/vz6ZjtyZ51TW ZxcnKXSzuCqvhSdgknLEA/ET4T7TcSXzKKs4jOSCAluSYHou7bJrZny2UrmwObc8ZNAw g3SaXKAUyA3/YgElfrbzzkNGHk0FIZmKtCqsoVs0LL35gI6jmhg3zoENCFsweQRsGTV0 L3Ab6J0y0Iw49O38+B/0oDM07sfOQR8ck9gjDHpYpDFq0D/4J3+0pPNLsAEuxm4mwL3Z SGqRl+5+81rnyD0/OikoQ3mO3qySjJxVpsDYI1T8BXJI9b+HoN2Fz1rjp4REpUAq59R9 BMhg== X-Gm-Message-State: AOJu0YySXse/vrqwYsK244TxFR1IALlHS0Q2+4dtANoObm3gV61LPmKr nnb+Ta16bFWRBmddzYPL8VjlYBi5cDEsnd9E57wGEmrQGVoYkW6DxenVdh5FH28LPc0ablVg3pX TDA== X-Received: by 2002:a05:6512:3605:b0:52c:dfa7:53a2 with SMTP id 2adb3069b0e04-52ce185f761mr1650906e87.50.1719218985414; Mon, 24 Jun 2024 01:49:45 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd63b4785sm939277e87.15.2024.06.24.01.49.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2024 01:49:45 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jun 2024 11:49:42 +0300 Message-Id: <20240624084944.14276-2-martin@martin.st> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240624084944.14276-1-martin@martin.st> References: <20240624084944.14276-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] hlsenc: Fix setting vs->start_pos when not using HLS_SINGLE_FILE or hls_segment_size 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 Cc: lq@chinaffmpeg.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6Bk12/zLnUg6 When not using HLS_SINGLE_FILE or hls_segment_size, we're writing each segment into a separate file. In that case, the file start pos for each segment will be zero. This matches the case in (hls->max_seg_size > 0) above, where we decide to switch to a new file. This fixes the calculation of "vs->size = new_start_pos - vs->start_pos" at the start of hls_write_packet; previously, start_pos would refer to the byte size of the previous segment file, giving vs->size entirely bogus values here. --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 3d5eb47e84..0c72774e29 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2659,7 +2659,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) vs->start_pos = new_start_pos; } } else { - vs->start_pos = new_start_pos; + vs->start_pos = 0; sls_flag_file_rename(hls, vs, old_filename); ret = hls_start(s, vs); } From patchwork Mon Jun 24 08:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 50117 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp1867514vqz; Mon, 24 Jun 2024 01:50:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX+3X9bmwrHOIv4GSvvN9oCWF07TdXlrNBJqN6SOJB+DKNa7xN2S8CnjVt0W0c43HZDlSqrEft+vL3UkbTr9oWBKww8OaYlbS7/3g== X-Google-Smtp-Source: AGHT+IG+RrQvhqMDZXc2+Itttkk9f9obQcYJz++qPo/7I7gmJ7CM4uPzdo+DTpwlC34KrEQNUujJ X-Received: by 2002:a17:906:fb0c:b0:a6e:f646:6fdb with SMTP id a640c23a62f3a-a7245c7025emr227189466b.72.1719219020081; Mon, 24 Jun 2024 01:50:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719219020; cv=none; d=google.com; s=arc-20160816; b=MtU6ONOqm/YiQh4NuSqwM1pvl15sRg8ocLNMZbcGU70vtZr5BHwHKh9buHA8GAo71X OlEkEZvcKwLNLjzMCs1SYATrBEFtxWC9JICMYXmD832PFD2BOZNAYtWcFiicMiJT346R 3U/PYuV0GOu6wimW58zEv++zeSpozCrcAUxPqmNlIlZ3ZwVbsgCoZ3y5K9HzB8nlgpR5 UtM6aCd5KwUeHzV3y6+6QjxiClYesqOfe/qNwXJQQHBxjnzXwEHr8xpAtqcdE875rQWm af2M5Y2stzX3MXMN4HGY50k0U37DZIzv2ClLNL3YVjUx7FTBzjBHLvnY4RsxmncoyOBw wCqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ndGSzu2Nf2mSGUdg9+ShfP1yge43e1Mkjx3F8YGa60Q=; fh=UvIsH30fhBXMmPtaePKJMeMspabJNvEuvy3Hi3mTDRo=; b=0wWkxmmrHZHZ2E79TSUpUJZITRUPYCycfi9VMZ04zy9+qn+9n/RFHPsdfHgrIj9yZJ iGnHrirftzuLvddxBQed+JUcjtUaMYWUbuRLMlEC2Nt52vinfQkbhnvNZkdENZVT5dsN N5N45SATjzR7gZRplBfr0Inv+k28KZfOnSCcPyx2Q0Anc6xNgC8sA0IYHURWEsBJnhSY u/7NXJg92ggdudSRGv5TqMuB1/C2Mqng5L+Z/IpLcwMS1RSLBar98+Zgpb4epBGEHTR8 oa1fKYcvrbHxbomZr9vN3NdiBir5prffMfzf7pdd9OpXbo2RSqK0B7fsBMLKskagKaYr Os6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=yXb35uB5; 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 a640c23a62f3a-a7254d5857fsi77605866b.527.2024.06.24.01.50.19; Mon, 24 Jun 2024 01:50:20 -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=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=yXb35uB5; 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 C1DBD68D641; Mon, 24 Jun 2024 11:49:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D35F368C0EB for ; Mon, 24 Jun 2024 11:49:46 +0300 (EEST) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2ec1620a956so48328191fa.1 for ; Mon, 24 Jun 2024 01:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1719218986; x=1719823786; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HFDlmPBUQ6+4WP4ofzLQqYHg7nC+vIDhSRmyTz0HlHo=; b=yXb35uB5sbc1edTvDMnQXWgmTX+RXfM6qmOtuMp0Mj2KhOchz98otcvy3CcBOXllqF iRVZIe3fXPdBPjkkLrwLB8LKQSPQzrAz/ojbFKW8W6wCtbIr0dZS/l/8YHbDJxf8coS+ U3G/BuEm1N9GVuaOLYMpTs18phy0anWasVjeYeAXRKbSrNaw9gX3tVHtFGSgBX7kBQAA 2C0BOaMoxvMshTL2atrullETfq3oBjUO+c7CLTnc8qsZrEi3lutLTvN0e0TeWPxnj00s Ayp2ae5zSICFzbmMj2mPOJtE3T5cczcQIFwMgHp8SUQ+Tw7CpSG3e00NIuC2T4mZg/7W j3ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719218986; x=1719823786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HFDlmPBUQ6+4WP4ofzLQqYHg7nC+vIDhSRmyTz0HlHo=; b=D1oq5t679ZNXm7rqVanAgKY6idCDgxYimorrisRJG+tVYy4wyaihbcKoPuBUqfE91w QLDIptq/Tb3b3UcwaL4hHbKw7vvxkNWmhb5zeILYb3sW1NOitf0EUSxOEwTpe/0y73Ma +fvRb4TnUYx7NkqyOt7eQKulSW60ddpLaltYsjErE1k7oaa7lsNEUwLSTvzWN+/afCA+ mfqS87NwTMtB2S8icTSdv9PZGgAFSuRO0r8QObFArPHb5wlX2X/4uTnEiOPsaMU4PYx0 f3QxibEejijAG20e8pcjx8Jyd+2IxC35Ra90bVnF8y+1M8R1DaFm1Blxfpqw/YGGaSag WW1w== X-Gm-Message-State: AOJu0YzfuYfo/U6k0bnlwC6zdAZTEfSJ07WNUcCcsci9HxsPN2ygoikh 0oTm7VtmgI48p6ahvLcrxHaUKnRJkywD0oT3QjwPEKE0jPTAr0/L7Fz8OAx8UXGr6j8pvRjPZBE 1Zg== X-Received: by 2002:a2e:2e0a:0:b0:2ec:6639:120a with SMTP id 38308e7fff4ca-2ec6639130cmr2379961fa.10.1719218986018; Mon, 24 Jun 2024 01:49:46 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec5b93e5fdsm4676811fa.115.2024.06.24.01.49.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2024 01:49:45 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jun 2024 11:49:43 +0300 Message-Id: <20240624084944.14276-3-martin@martin.st> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240624084944.14276-1-martin@martin.st> References: <20240624084944.14276-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] hlsenc: When not using HLS_SINGLE_FILE, set vs->size to range_length 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 Cc: lq@chinaffmpeg.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IPVcaX813Nw9 This matches what is done in the corresponding case for HLS_SINGLE_FILE. Normally, vs->size is already initialized correctly - but when writing the initial segment, with mp4 files, vs->size has been set to the size of the init segment, while range_length contains the real size of the first segment. --- libavformat/hlsenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 0c72774e29..3ca99abdbb 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2586,6 +2586,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) av_dict_free(&options); return ret; } + vs->size = range_length; ret = hlsenc_io_close(s, &vs->out, filename); if (ret < 0) { av_log(s, AV_LOG_WARNING, "upload segment failed," From patchwork Mon Jun 24 08:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 50118 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:ae71:0:b0:482:c625:d099 with SMTP id w17csp1867619vqz; Mon, 24 Jun 2024 01:50:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWwmIaVnRhg2YWa6162f88I8y9aTu3SABEJQmEH55VEHMl566/OeOvvFE726ywhYxkqh/uJLo9CymOXxZABNJRq5EkaB3QfbW6xiA== X-Google-Smtp-Source: AGHT+IFRYaptrLLqaituOP/+931aXLHYeFhlAoPS2eWJcaNevSgU7cS3S2XLmg4CHDvaqXNe2K6P X-Received: by 2002:ac2:5f4c:0:b0:52c:d9c6:68c8 with SMTP id 2adb3069b0e04-52ce0646938mr3178036e87.65.1719219031344; Mon, 24 Jun 2024 01:50:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719219031; cv=none; d=google.com; s=arc-20160816; b=YtQBavqAUwho9gNXnxhEHzEkpxIvssFb4RImAYyKXw4y2OhLFq4lAS8gAVFRYia5kK mG9Jk3vsEIxom+mM9ZwSXOPkIMaRCIZv1z+K0z/3jb2lGytVgMdZcALVHCPHgtwRdgN8 faIn4WhKNrI4JUk6l760VYNnRRhzbZukohzDjOVFGTuTPuHT682Ni7yufVCeFqr6+FQJ 1t22a2yxVpCpAlculkBOJsflRpQDTA/3QxTBe0gXc8FTggB5t1xIxkbEMddZ1tbgIpWv XpgGcLit4bl8jxc2TqfsR3N9fSGJ/ne8cLTHfBUWreXnLj1cBMwxA9rnJIOiA5qUK+qx Yt8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=AyZCcVXAVlrrkwuHiqMHp0zy+8l80oUWVqlrBJ50+Tg=; fh=UvIsH30fhBXMmPtaePKJMeMspabJNvEuvy3Hi3mTDRo=; b=CN6cwDK2BNdGonnCJCqW01KbgQp72D1g9Le8l2PLpltdCKsSPudtEvXIlVumtcx9Sy E0thFoxBRGcVM5io+zp9Jj2kWt6UQsHRF/YtOwq2OIva11NRUWsDlt/OzHjW2jZQ9QiK gMv4TjyOl24FwcUaNIFVlAuCgZ5UU03EWwqgCYg1ROlar4o5jmCX7auxpTJ4p0rnF6aF oMrfEqkIEbL2FtgRIsybxEt+FtN5358KErpFJJE2rpucH1zIerwIiDGhRgpivMAsS3GQ 6dVix3EVX0UY6UfRVXC7b/EVtlVr6OTXt58aUce4J7eZt8aSr9dptjhTLGS57EPujMA5 Y8jQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=rHA8zoa2; 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 2adb3069b0e04-52cd63bca03si2069330e87.155.2024.06.24.01.50.30; Mon, 24 Jun 2024 01:50:31 -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=@martin-st.20230601.gappssmtp.com header.s=20230601 header.b=rHA8zoa2; 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 D065A68D631; Mon, 24 Jun 2024 11:49:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EF8168D607 for ; Mon, 24 Jun 2024 11:49:47 +0300 (EEST) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ebed33cb65so44889671fa.2 for ; Mon, 24 Jun 2024 01:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1719218986; x=1719823786; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ovBNJqtaentgVtQEXlyPygZISuo2WWXb8Qyqt0eVvkk=; b=rHA8zoa2DwIwehlYTzwpiPW9F9tcesly7koySopakW6cmtf7/A84QQp/pQt1R/L9Ib FkGXo3Uq9h93Tqg9Yv6btUr/U2N6TY8/nIwxY12VUD9S6plByIdjy/3+OAMZYJ7lpI9L vwvGr3tL9mBeNgmusc50MEKHyx9Ca1kCkGmWHY6aiZzMx00Y6UPUVoJVUnbUGQ4Slosc 81lnnpBrXkJ+1TsJMB3hnVeC+//EyrImjBxfOT3gHn6Zy9wkCaJ/FOMtgpmR9qhC2Ee4 nmldJ0WTa7XIb+5zc6q5ummrRY/p9IL4PGvY/aWyyWDkEeRouJ091xUtgKap3GOtR//5 vzRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719218986; x=1719823786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ovBNJqtaentgVtQEXlyPygZISuo2WWXb8Qyqt0eVvkk=; b=xPrPc0ZdOTzq3I3MLnQBx177H2eLykP/BnH8IzSUtZjzOlvy6HpNgktNBSB4KC1XII xOcLGpHSJSUXQrj2x/05eL33sXQUHMDun3c2XRUB1ydTs3O5G5C5MIWEGI86KFjDWQqz otMmbdKoNTjWGqo19s9weO8f6xJAcY122T4PG0IHTlxfqUIipeWHNfQAJJ40JPnuVwty tgz6Xh5L7RDfk0T/h+OM0YOOK5C4lPHTzS5QtvM43Y/MUGYQAmUcTiZSeXn+00e0cdwe 5nVZtHZ1hJ+DqU1fyANHwsv3/4lVwAo5LNdK0tOwxyyZKCGg/DhK8VFEs0pGAteD6NbP rp/g== X-Gm-Message-State: AOJu0Yx6Eu0w2ID8WxDdWGdqFDSMQUBp5pYGMnxvbO7PY1NxXxylLCBx nJ43ch/EE/twOv0K0OceHv30x0TqQ4dcMXrW7HleDr9w1W27Xcb/2tFmuTagyNobgOFgvrbXIXD ZvA== X-Received: by 2002:a2e:9859:0:b0:2eb:f0ed:a36d with SMTP id 38308e7fff4ca-2ec5931d44cmr34179111fa.19.1719218986606; Mon, 24 Jun 2024 01:49:46 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4e07e08esm9056611fa.24.2024.06.24.01.49.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 24 Jun 2024 01:49:46 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 24 Jun 2024 11:49:44 +0300 Message-Id: <20240624084944.14276-4-martin@martin.st> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <20240624084944.14276-1-martin@martin.st> References: <20240624084944.14276-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] hlsenc: Calculate the average and actual maximum bitrate of segments 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 Cc: lq@chinaffmpeg.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OCpdUoAajIUk Previously, the bitrate advertised in the master playlist would only be based on the nominal values in either AVCodecParameters bit_rate, or via AVCPBProperties max_bitrate. On top of this, a fudge factor of 10% is added, to account for container overhead. Neither of these bitrates may be known, and if the encoder is running in VBR mode, there is no such value to be known. And the container overhead may be more or less than the given constant factor of 10%. Instead, calculate the maximum bitrate per segment based on what actually gets output from the muxer, and average bitrate across all segments. When muxing of the file finishes, update the master playlist with these values, exposing both the maximum (which previously was a guesstimate based on the nominal values) via EXT-X-STREAM-INF BANDWIDTH, and the average via EXT-X-STREAM-INF AVERAGE-BANDWIDTH. This makes it possible to use the hlsenc muxer with VBR encodes, for VOD style muxing. --- libavformat/dashenc.c | 4 ++-- libavformat/hlsenc.c | 47 ++++++++++++++++++++++++++++----------- libavformat/hlsplaylist.c | 3 +++ libavformat/hlsplaylist.h | 1 + 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 8c14aa746e..d4a6fe0304 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1322,7 +1322,7 @@ static int write_manifest(AVFormatContext *s, int final) av_strlcat(codec_str, audio_codec_str, sizeof(codec_str)); } get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); - ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate, + ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate, 0, playlist_file, agroup, codec_str, NULL, NULL); } @@ -1348,7 +1348,7 @@ static int write_manifest(AVFormatContext *s, int final) continue; av_strlcpy(codec_str, os->codec_str, sizeof(codec_str)); get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, i); - ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate, + ff_hls_write_stream_info(st, c->m3u8_out, stream_bitrate, 0, playlist_file, NULL, codec_str, NULL, NULL); } diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 3ca99abdbb..26722c9b32 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -150,6 +150,11 @@ typedef struct VariantStream { int discontinuity; int reference_stream_index; + int64_t total_size; + double total_duration; + int64_t avg_bitrate; + int64_t max_bitrate; + HLSSegment *segments; HLSSegment *last_segment; HLSSegment *old_segments; @@ -1108,6 +1113,16 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, if (!en) return AVERROR(ENOMEM); + vs->total_size += size; + vs->total_duration += duration; + if (duration > 0) { + int cur_bitrate = (int)(8 * size / duration); + if (cur_bitrate > vs->max_bitrate) + vs->max_bitrate = cur_bitrate; + } + if (vs->total_duration > 0) + vs->avg_bitrate = (int)(8 * vs->total_size / vs->total_duration); + en->var_stream_idx = vs->var_stream_idx; ret = sls_flags_filename_process(s, hls, vs, en, duration, pos, size); if (ret < 0) { @@ -1362,14 +1377,15 @@ static int64_t get_stream_bit_rate(AVStream *stream) } static int create_master_playlist(AVFormatContext *s, - VariantStream * const input_vs) + VariantStream * const input_vs, + int final) { HLSContext *hls = s->priv_data; VariantStream *vs, *temp_vs; AVStream *vid_st, *aud_st; AVDictionary *options = NULL; unsigned int i, j; - int ret, bandwidth; + int ret, bandwidth, avg_bandwidth; const char *m3u8_rel_name = NULL; const char *vtt_m3u8_rel_name = NULL; const char *ccgroup; @@ -1389,8 +1405,8 @@ static int create_master_playlist(AVFormatContext *s, return 0; } else { /* Keep publishing the master playlist at the configured rate */ - if (&hls->var_streams[0] != input_vs || !hls->master_publish_rate || - input_vs->number % hls->master_publish_rate) + if ((&hls->var_streams[0] != input_vs || !hls->master_publish_rate || + input_vs->number % hls->master_publish_rate) && !final) return 0; } @@ -1480,12 +1496,17 @@ static int create_master_playlist(AVFormatContext *s, } } - bandwidth = 0; - if (vid_st) - bandwidth += get_stream_bit_rate(vid_st); - if (aud_st) - bandwidth += get_stream_bit_rate(aud_st); - bandwidth += bandwidth / 10; + if (final) { + bandwidth = vs->max_bitrate; + avg_bandwidth = vs->avg_bitrate; + } else { + bandwidth = 0; + if (vid_st) + bandwidth += get_stream_bit_rate(vid_st); + if (aud_st) + bandwidth += get_stream_bit_rate(aud_st); + bandwidth += bandwidth / 10; + } ccgroup = NULL; if (vid_st && vs->ccgroup) { @@ -1514,11 +1535,11 @@ static int create_master_playlist(AVFormatContext *s, } if (!hls->has_default_key || !hls->has_video_m3u8) { - ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name, + ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, avg_bandwidth, m3u8_rel_name, aud_st ? vs->agroup : NULL, vs->codec_attr, ccgroup, sgroup); } else { if (vid_st) { - ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name, + ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, avg_bandwidth, m3u8_rel_name, aud_st ? vs->agroup : NULL, vs->codec_attr, ccgroup, sgroup); } } @@ -1671,7 +1692,7 @@ fail: ff_rename(temp_vtt_filename, vs->vtt_m3u8_name, s); } if (ret >= 0 && hls->master_pl_name) - if (create_master_playlist(s, vs) < 0) + if (create_master_playlist(s, vs, last) < 0) av_log(s, AV_LOG_WARNING, "Master playlist creation failed\n"); return ret; diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c index 4f35d0388f..f8a6977702 100644 --- a/libavformat/hlsplaylist.c +++ b/libavformat/hlsplaylist.c @@ -71,6 +71,7 @@ void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, } void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, + int avg_bandwidth, const char *filename, const char *agroup, const char *codecs, const char *ccgroup, const char *sgroup) @@ -85,6 +86,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, } avio_printf(out, "#EXT-X-STREAM-INF:BANDWIDTH=%d", bandwidth); + if (avg_bandwidth) + avio_printf(out, ",AVERAGE-BANDWIDTH=%d", avg_bandwidth); if (st && st->codecpar->width > 0 && st->codecpar->height > 0) avio_printf(out, ",RESOLUTION=%dx%d", st->codecpar->width, st->codecpar->height); diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h index c2744c227c..d7aa44d8dc 100644 --- a/libavformat/hlsplaylist.h +++ b/libavformat/hlsplaylist.h @@ -43,6 +43,7 @@ void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, int name_id, int is_default); void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, + int avg_bandwidth, const char *filename, const char *agroup, const char *codecs, const char *ccgroup, const char *sgroup);