From patchwork Wed May 11 08:16:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 35728 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3781292pzb; Wed, 11 May 2022 01:18:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNmmWXldXkck7qSU3Wq5otmmLw6xzqtx8ln03w5/iMARwYePSCOR/NvHtukzNZZHNjcDQX X-Received: by 2002:a17:907:6d24:b0:6f4:bc43:e7d1 with SMTP id sa36-20020a1709076d2400b006f4bc43e7d1mr22740741ejc.581.1652257112985; Wed, 11 May 2022 01:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652257112; cv=none; d=google.com; s=arc-20160816; b=ZQCWhR+cgGLv4gqXjlX9lr70jIGXxWyScPplGoUnR99SxGXCuwI3MQdfyWF+rcDNhb 55ALgOs3mpb3/hCemzZOZF4wHgZmTMJzP09Y0YTy/nsDKmxSL7v/Uvh241hZe5BBUU9c CQLAV63ScEemAMbZXw3TB9hLAvivhAfUVoGdkeTaCqaDyuAB8Y53X8HtFUPrhs3poDQi sFsdrmwcD22Q4h+eqdwBys1l8gcCm1+xZx4x+nN8Z/xoDrh7V3sKe1a/eMWIALwxZErf pF4S+Qgyo8Wo8kqZzTYFLEap6D16TZjD3zfPi4GABMR0PltsWdC1L65T3UY6TQXFjyCf rwFQ== 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=Gl60HweIdEGH1zD3payprv2Wwpiy1KzmzyZP1EMZvoU=; b=EHEJI86qcYinUc8Sn26Adeas1fdn37qxzbSIAkIl2AQNDj7+OZcitzsQ0mhhDzvOSO nlxkhtgvN8kcZIQcvF+wST7Zh9mWY4POo3T8X8LOBbJfidVfgr3kFr7npwX13fdu+QLp jslweWUlhxLKXchdxes+chiRxK/v2l8VEQiDgQBGPp0pX+A+RfyUxNDbpTiN25+JaC1x veO0cC+BPZ5tTTNGgKcry/j6nlswvruzVw/yI8+niL6cMffjk3E4N1M4LNonQmPTV3sl 7oHb8usri0RcrtwXhCy+D9Ky5z6/fyBafLQQXk3OxcsXMsCIcanrZwPb7abXKxCUPFDW UJqA== 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 g17-20020a1709065d1100b006e86c3056c2si1852210ejt.33.2022.05.11.01.18.32; Wed, 11 May 2022 01:18:32 -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 4083B68B457; Wed, 11 May 2022 11:17:24 +0300 (EEST) 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 5F67668B423 for ; Wed, 11 May 2022 11:17:15 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B7F65240507 for ; Wed, 11 May 2022 10:17:11 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id WRVg16njpYAj for ; Wed, 11 May 2022 10:17:11 +0200 (CEST) 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 C961224050B for ; Wed, 11 May 2022 10:17:07 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id B07863A07AE; Wed, 11 May 2022 10:17:02 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 May 2022 10:16:51 +0200 Message-Id: <20220511081654.15127-6-anton@khirnov.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220511081654.15127-1-anton@khirnov.net> References: <20220511081654.15127-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop using AVStream.nb_frames in do_video_stats() 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: eVnW8wWCsey8 Its use for muxing is not documented, in practice it is incremented per each packet successfully passed to the muxer's write_packet(). Since there is a lot of indirection between ffmpeg receiving a packet from the encoder and it actually being written (e.g. bitstream filters, the interleaving queue), using nb_frames here is incorrect. Add a new counter for packets received from encoder instead. --- fftools/ffmpeg.c | 4 +++- fftools/ffmpeg.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ae3cc57bef..c15d1486dd 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -851,7 +851,7 @@ static void do_video_stats(OutputStream *ost, int frame_size) } enc = ost->enc_ctx; - frame_number = ost->st->nb_frames; + frame_number = ost->packets_encoded; if (vstats_version <= 1) { fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, ost->quality / (float)FF_QP2LAMBDA); @@ -945,6 +945,8 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame) if (enc->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) do_video_stats(ost, pkt->size); + ost->packets_encoded++; + output_packet(of, pkt, ost, 0); /* if two pass, output log */ diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 9f0c093e34..7326193caf 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -551,6 +551,8 @@ typedef struct OutputStream { // number of frames/samples sent to the encoder uint64_t frames_encoded; uint64_t samples_encoded; + // number of packets received from the encoder + uint64_t packets_encoded; /* packet quality factor */ int quality;