[Ffmpeg-devel] [PATCH] add fps stats
Limin Wang
lance.lmwang
Wed Mar 14 12:36:30 CET 2007
Hi,
The patch try to add fps stats for ffmpeg, then I don't need to
time ffmpeg and calculate the fps every time. Please review it.
Thanks,
Limin
-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c (revision 8396)
+++ ffmpeg.c (working copy)
@@ -205,6 +205,7 @@
int opt_name_count=0;
AVCodecContext *avctx_opts[CODEC_TYPE_NB];
AVFormatContext *avformat_opts;
+static int64_t timer_start = 0;
static AVBitStreamFilterContext *video_bitstream_filters=NULL;
static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
@@ -925,9 +926,14 @@
enc->coded_frame->quality/(float)FF_QP2LAMBDA);
}
if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
+ float t;
+
+ t = (av_gettime()-timer_start) / 1000000.0;
+
frame_number = ost->frame_number;
- snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d q=%3.1f ",
- frame_number, enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
+ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
+ frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
+ enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist && enc->coded_frame){
@@ -1808,7 +1814,8 @@
term_init();
key = -1;
-
+ timer_start = av_gettime();
+
for(; received_sigterm == 0;) {
int file_index, ist_index;
AVPacket pkt;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070314/79083e7b/attachment.pgp>
More information about the ffmpeg-devel
mailing list