odrling-overlay/media-libs/x264/files/enc-time.patch
2021-05-02 22:21:02 +02:00

84 lines
3.7 KiB
Diff

From 49d36068a4bf958b553c62fe6f47ef2d81cbf8f6 Mon Sep 17 00:00:00 2001
From: DJATOM <djatom@beatrice-raws.org>
Date: Tue, 26 Jan 2021 00:57:07 +0200
Subject: [PATCH] Improve encoding status view Extend final stats
---
x264.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/x264.c b/x264.c
index 11dd6c6e..bc2415c3 100644
--- a/x264.c
+++ b/x264.c
@@ -1932,11 +1932,24 @@ static int encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *la
static int64_t print_status( int64_t i_start, int64_t i_previous, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
{
+ static int print_progress_header = 1;
char buf[200];
int64_t i_time = x264_mdate();
if( i_previous && i_time - i_previous < UPDATE_INTERVAL )
return i_previous;
+
+ if( print_progress_header )
+ {
+ if( i_frame_total )
+ fprintf( stderr, " %6s %13s %5s %8s %9s %9s\n",
+ "", "frames ", "fps ", "kb/s ", "elapsed", "remain " );
+ else
+ fprintf( stderr, "%6s %5s %8s %9s\n", "frames", "fps ", "kb/s ", "elapsed" );
+ print_progress_header = 0;
+ }
+
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 )
@@ -1946,12 +1959,13 @@ 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 %5.2f %8.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 %5.2f %8.2f %3d:%02d:%02d",
+ i_frame, fps, bitrate, secs/3600, (secs/60)%60, secs%60 );
fprintf( stderr, "%s \r", buf+5 );
x264_cli_set_console_title( buf );
fflush( stderr ); // needed in windows
@@ -2138,8 +2152,11 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
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" );
@@ -2154,9 +2171,11 @@ static int encode( x264_param_t *param, cli_opt_t *opt )
{
double fps = (double)i_frame_output * (double)1000000 /
(double)( i_end - i_start );
+ int secs = (i_end - i_start) / 1000000;
- x264_cli_printf( X264_LOG_INFO, "encoded %d frames, %.2f fps, %.2f kb/s\n", i_frame_output, fps,
- (double) i_file * 8 / ( 1000 * duration ) );
+ x264_cli_printf( X264_LOG_INFO, "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;