fftools/ffmpeg: print keyframe information with -stats_*

This commit is contained in:
Anton Khirnov 2023-12-14 19:26:56 +01:00
parent 23c00d8c89
commit 02a4393647
4 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -465,6 +465,7 @@ enum EncStatsType {
ENC_STATS_PKT_SIZE,
ENC_STATS_BITRATE,
ENC_STATS_AVG_BITRATE,
ENC_STATS_KEYFRAME,
};
typedef struct EncStatsComponent {

View File

@ -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);

View File

@ -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;