[x264-devel] Print elapsed time in encoding progress indicator
Alexander Prikhodko
git at videolan.org
Tue Jul 17 21:21:41 CEST 2012
x264 | branch: master | Alexander Prikhodko <komisar666 at gmail.com> | Tue Jun 12 20:21:35 2012 +0300| [8b535d9006d87e32c4ff939691b920da823ae85a] | committer: Jason Garrett-Glaser
Print elapsed time in encoding progress indicator
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=8b535d9006d87e32c4ff939691b920da823ae85a
---
x264.c | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/x264.c b/x264.c
index 8dcc655..0744133 100644
--- a/x264.c
+++ b/x264.c
@@ -1694,6 +1694,7 @@ static int64_t print_status( int64_t i_start, int64_t i_previous, int i_frame, i
if( i_previous && i_time - i_previous < UPDATE_INTERVAL )
return i_previous;
int64_t i_elapsed = i_time - i_start;
+ int secs = i_elapsed / 1000000;
double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
double bitrate;
if( last_ts )
@@ -1703,13 +1704,14 @@ static int64_t print_status( int64_t i_start, int64_t i_previous, int i_frame, i
if( i_frame_total )
{
int eta = i_elapsed * (i_frame_total - i_frame) / ((int64_t)i_frame * 1000000);
- sprintf( buf, "x264 [%.1f%%] %d/%d frames, %.2f fps, %.2f kb/s, eta %d:%02d:%02d",
+ sprintf( buf, "x264 [%5.1f%%] %6d/%-6d %6.2f %9.2f %3d:%02d:%02d %3d:%02d:%02d",
100. * i_frame / i_frame_total, i_frame, i_frame_total, fps, bitrate,
- eta/3600, (eta/60)%60, eta%60 );
+ secs/3600, (secs/60)%60, secs%60, eta/3600, (eta/60)%60, eta%60 );
}
else
{
- sprintf( buf, "x264 %d frames: %.2f fps, %.2f kb/s", i_frame, fps, bitrate );
+ sprintf( buf, "x264 %6d %6.2f %9.2f %3d:%02d:%02d",
+ i_frame, fps, bitrate, secs/3600, (secs/60)%60, secs%60 );
}
fprintf( stderr, "%s \r", buf+5 );
SetConsoleTitle( buf );
@@ -1799,6 +1801,14 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
if( opt->tcfile_out )
fprintf( opt->tcfile_out, "# timecode format v2\n" );
+ if( opt->b_progress )
+ {
+ if( param->i_frame_total )
+ fprintf( stderr, " %6s %13s %6s %9s %9s %9s\n", "", "frames ", "fps ", "kb/s ", "elapsed", "remain " );
+ else
+ fprintf( stderr, "%6s %6s %9s %9s\n", "frames", "fps ", "kb/s ", "elapsed" );
+ }
+
/* Encode frames */
for( ; !b_ctrl_c && (i_frame < param->i_frame_total || !param->i_frame_total); i_frame++ )
{
@@ -1894,8 +1904,11 @@ fail:
i_end = x264_mdate();
/* Erase progress indicator before printing encoding stats. */
- if( opt->b_progress )
- fprintf( stderr, " \r" );
+ if( opt->b_progress && i_frame_output )
+ {
+ print_status( i_start, 0, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
+ fprintf( stderr, "\n" );
+ }
if( h )
x264_encoder_close( h );
fprintf( stderr, "\n" );
@@ -1910,9 +1923,11 @@ fail:
{
double fps = (double)i_frame_output * (double)1000000 /
(double)( i_end - i_start );
+ int secs = (i_end - i_start) / 1000000;
- fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame_output, fps,
- (double) i_file * 8 / ( 1000 * duration ) );
+ fprintf( stderr, "encoded %d frames, %.2f fps, %.2f kb/s, duration %d:%02d:%02d.%02d\n", i_frame_output, fps,
+ (double) i_file * 8 / ( 1000 * duration ),
+ secs/3600, (secs/60)%60, secs%60, (int)((i_end - i_start)%1000000/10000) );
}
return retval;
More information about the x264-devel
mailing list