Browse code

add fps stats, patch by Limin Wang <lance lmwang at gmail com>

Originally committed as revision 8422 to svn://svn.ffmpeg.org/ffmpeg/trunk

Limin Wang authored on 2007/03/17 01:13:54
Showing 1 changed files
... ...
@@ -205,6 +205,7 @@ const char **opt_names=NULL;
205 205
 int opt_name_count=0;
206 206
 AVCodecContext *avctx_opts[CODEC_TYPE_NB];
207 207
 AVFormatContext *avformat_opts;
208
+static int64_t timer_start = 0;
208 209
 
209 210
 static AVBitStreamFilterContext *video_bitstream_filters=NULL;
210 211
 static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
... ...
@@ -925,9 +926,12 @@ static void print_report(AVFormatContext **output_files,
925 925
                     enc->coded_frame->quality/(float)FF_QP2LAMBDA);
926 926
         }
927 927
         if (!vid && enc->codec_type == CODEC_TYPE_VIDEO) {
928
+            float t = (av_gettime()-timer_start) / 1000000.0;
929
+
928 930
             frame_number = ost->frame_number;
929
-            snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d q=%3.1f ",
930
-                    frame_number, enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
931
+            snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
932
+                     frame_number, (t>1)?(int)(frame_number/t+0.5) : 0,
933
+                     enc->coded_frame ? enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1);
931 934
             if(is_last_report)
932 935
                 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
933 936
             if(qp_hist && enc->coded_frame){
... ...
@@ -1808,6 +1812,7 @@ static int av_encode(AVFormatContext **output_files,
1808 1808
     term_init();
1809 1809
 
1810 1810
     key = -1;
1811
+    timer_start = av_gettime();
1811 1812
 
1812 1813
     for(; received_sigterm == 0;) {
1813 1814
         int file_index, ist_index;