From patchwork Mon Dec 13 15:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 32423 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5572542iog; Mon, 13 Dec 2021 07:22:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJypCVMMA3UbWgM12vwN1d1VscUXikfuDt3lo3z1Kabmd3Yvz1wSIKea05QaDfAvWUrzOoof X-Received: by 2002:aa7:cc82:: with SMTP id p2mr63379633edt.201.1639408966090; Mon, 13 Dec 2021 07:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639408966; cv=none; d=google.com; s=arc-20160816; b=cgsuy3plrWueObfUKuHfhCoPWec42g3PvKkJWDhKV2g+AqvSavyUYxKyUQovHLwbUz +WAm3bJvqwPxopVIlWFScaTeL86MIQyHoTsG/+wNm6r+RLUMEPqViyw4+KIJg5IgyKFV 7/zit5zWwC1qYskzCHKVcu/YpE1ML6XIrZcbEECHbHJbUN5LYJnOcJ1dIrplDjlMGPPk kZDQamUqKPB1TngXLIPV6+pQ69JA/F/bpPliyzJTnAGw17+AfVJUg3fQ/K0CZvezcoUD uYPDvjDhQ/igmAb2sypb9dBmXcwnFk5F3QDXaqfDJ3PZbdGq4pzSd6ZVnb4sVq/SIRgS H5Ig== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=xRpL+4WM+nBKjWJcK4CXLMTmf2EJChjVjcs/BfaXSmI=; b=lVwLqG+4cz5VvBx/ksRam0f70TmwuY665rkRYObiRaafNEDp+RZ6hreNmCrnYJDjVu PrxFUZoUx0GgnuGfm5NZxha4InHPess6MM6QxU2uwt39QTH9sty7EF9hB1bdgubsvV8Z uIJWbb7vrgPnd6HBqtvyRWMDfgW6AeGMRxJoF9fOf5M10dYeU2bc5rn1OtrT7ami69Xx hbnD1+WyMhbnppXKy+85pRNWkAryZE8gGRy9MkQTwQbXMlikx7YG6dl62502fj6pB8tD 6mIzZqPZCbolfSSY7y0doYZSTM7+YtAT5wrMEcE0CCKyrBmUn75A22+2jA0s/TbwM1u4 L7OA== 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 r11si643603ejr.881.2021.12.13.07.22.45; Mon, 13 Dec 2021 07:22:46 -0800 (PST) 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 20E1968AF94; Mon, 13 Dec 2021 17:22:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 34BCB68807F for ; Mon, 13 Dec 2021 17:22:09 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D2CE5240179 for ; Mon, 13 Dec 2021 16:22:08 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id gXWCGSa109vm for ; Mon, 13 Dec 2021 16:22:08 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 353F824017E for ; Mon, 13 Dec 2021 16:22:07 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 0D8EB3A00D9; Mon, 13 Dec 2021 16:22:07 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 13 Dec 2021 16:20:20 +0100 Message-Id: <20211213152042.5900-2-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211213152042.5900-1-anton@khirnov.net> References: <20211213152042.5900-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/24] ffmpeg: simplify getting output file 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9G4zH2wLiNdc Stop calling avio_size()/avio_tell(), which are potentially heavy operations and may interfere with muxer operation. Use the recently introduced bytes_written field instead. --- fftools/ffmpeg.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index bdeff9a12e..b77531cb7f 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1677,8 +1677,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti { AVBPrint buf, buf_script; OutputStream *ost; - AVFormatContext *oc; - int64_t total_size; + int64_t total_size = -1; AVCodecContext *enc; int frame_number, vid, i; double bitrate; @@ -1708,11 +1707,8 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti t = (cur_time-timer_start) / 1000000.0; - oc = output_files[0]->ctx; - - total_size = avio_size(oc->pb); - if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too - total_size = avio_tell(oc->pb); + if (output_files[0]->ctx->pb) + total_size = output_files[0]->ctx->pb->bytes_written; vid = 0; av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);