From patchwork Thu Dec 14 19:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp5185855pzf; Thu, 14 Dec 2023 11:33:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IFP9VfENa/wUsg36m29CNsDtgRCDVNDc4aeKjxMyxfO1WfxxIOFneFSLM94JSja2KDM59RH X-Received: by 2002:a17:907:d404:b0:a01:b8e5:d4b7 with SMTP id vi4-20020a170907d40400b00a01b8e5d4b7mr10144045ejc.1.1702582407398; Thu, 14 Dec 2023 11:33:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702582407; cv=none; d=google.com; s=arc-20160816; b=aWWRfxY3KlWY3aQVIrlRJLZLzo+q1MQt4ucWP50dNzRcX17BsCZ0p6s5LBQrHhbbE8 btplSL88cnn8Kx4MyFIWtKWJkld0rWaUb8U8BT6tP6vDfbUvIFHnBwRGWGe7Y7Ozy51S DLWilgi8EX6kcIjpkqCNtOw/Imggw5oqn3rlG4PsaDrSTXNfOSACrI//e61vt4X9SaMJ 6dN2Q6vAwOlAJf2WEO6q99NsTBmrjq4Zseuvi6oZztVITM2XdIvd87yxOx0IpvLur1GD 5nVsZVybX7omWNdJS+srOxf0LgAgdwxCcMVsxOzcOvVbmI2Z1b2faoi1aBITQuJM1mJA wGXg== 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=MtkRr0fEYa2KGpflyFVK6rBZDodzQkiuzXW+behzqqE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WQus+VE058+sQxuWPgG+i8bXMmMBcBeVKCuU8igD0zyY7+nbtooeh/JJUb/dLQAyeg VrqJm8VDr/1zJNmYQAZMFF8U4HQylPySQtdaLyvRCf5dHuoJDvK5WQFe3eh5A53uNUe7 rZBJ0v8VWBi7JDeOhR/WN8dkrdFJ8/jN241tX900zE2/ybBEXe1k44KddLg1LplxbsHe i/tc0V9QEogQ1JuWp4xhCNcyGrkf7gtS25GxjkDxkojH485iGdRgWBNC5lcl6+U1W6GS Hw+uLi41JvbJTQtEjz5vAQuvsN7mX6FcTjiSJCqYxWBNVILCk+IU+lcpxQ5l1aBnQ14g MPbQ== 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 q6-20020a170906a08600b00a1fa722b858si3557255ejy.981.2023.12.14.11.33.25; Thu, 14 Dec 2023 11:33:27 -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 8A8EC68D2A9; Thu, 14 Dec 2023 21:32:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6261568D292 for ; Thu, 14 Dec 2023 21:32:44 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 1423D1BA1 for ; Thu, 14 Dec 2023 20:32:44 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id 7bz2A8TlNtgn for ; Thu, 14 Dec 2023 20:32:43 +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 mail1.khirnov.net (Postfix) with ESMTPS id 842581BA3 for ; Thu, 14 Dec 2023 20:32:38 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 826813A0688 for ; Thu, 14 Dec 2023 20:32:31 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 14 Dec 2023 20:31:35 +0100 Message-ID: <20231214193138.2503-6-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214193138.2503-1-anton@khirnov.net> References: <20231214193138.2503-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: print keyframe information with -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: 6IX3Ldq6VazR --- doc/ffmpeg.texi | 3 +++ fftools/ffmpeg.h | 1 + fftools/ffmpeg_enc.c | 2 ++ fftools/ffmpeg_mux_init.c | 1 + 4 files changed, 7 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index f157c06e12..059102b75a 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -2207,6 +2207,9 @@ Current bitrate in bits per second. Post-encoding only. @item abr (@emph{packet}) Average bitrate for the whole stream so far, in bits per second, -1 if it cannot be determined at this point. Post-encoding only. + +@item key (@emph{packet}) +Character 'K' if the packet contains a keyframe, character 'N' otherwise. @end table Directives tagged with @emph{packet} may only be used with diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 96f4e757e1..03dbb528c0 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -465,6 +465,7 @@ enum EncStatsType { ENC_STATS_PKT_SIZE, ENC_STATS_BITRATE, ENC_STATS_AVG_BITRATE, + ENC_STATS_KEYFRAME, }; typedef struct EncStatsComponent { diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 9141dab6a4..d774a7e008 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -520,6 +520,8 @@ void enc_stats_write(OutputStream *ost, EncStats *es, case ENC_STATS_DTS: avio_printf(io, "%"PRId64, pkt->dts); continue; case ENC_STATS_DTS_TIME: avio_printf(io, "%g", pkt->dts * av_q2d(tb)); continue; case ENC_STATS_PKT_SIZE: avio_printf(io, "%d", pkt->size); continue; + case ENC_STATS_KEYFRAME: avio_write(io, (pkt->flags & AV_PKT_FLAG_KEY) ? + "K" : "N", 1); continue; case ENC_STATS_BITRATE: { double duration = FFMAX(pkt->duration, 1) * av_q2d(tb); avio_printf(io, "%g", 8.0 * pkt->size / duration); diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c index f870d48136..0203701d78 100644 --- a/fftools/ffmpeg_mux_init.c +++ b/fftools/ffmpeg_mux_init.c @@ -309,6 +309,7 @@ static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, { ENC_STATS_PKT_SIZE, "size", 0, 1 }, { ENC_STATS_BITRATE, "br", 0, 1 }, { ENC_STATS_AVG_BITRATE, "abr", 0, 1 }, + { ENC_STATS_KEYFRAME, "key", 0, 1 }, }; const char *next = fmt_spec;