[FFmpeg-cvslog] fftools/ffmpeg: print keyframe information with -stats_*
Anton Khirnov
git at videolan.org
Mon Dec 18 09:54:08 EET 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Dec 14 19:26:56 2023 +0100| [02a43936476ad69f4957c8444a740bdb394bde37] | committer: Anton Khirnov
fftools/ffmpeg: print keyframe information with -stats_*
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02a43936476ad69f4957c8444a740bdb394bde37
---
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.
+
+ at 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;
More information about the ffmpeg-cvslog
mailing list