]> granicus.if.org Git - libx264/commitdiff
Add title-bar progress indicator under WIN32
authorFiona Glaser <fiona@x264.com>
Wed, 10 Sep 2008 06:12:20 +0000 (23:12 -0700)
committerFiona Glaser <fiona@x264.com>
Wed, 10 Sep 2008 06:29:03 +0000 (23:29 -0700)
Also add bitrate-so-far output when piping data to x264 (total frames not known)
Patch mostly by recover from Doom9.

x264.c

diff --git a/x264.c b/x264.c
index b296cf102975d34d2a80112fa753ebd140654507..f472fd78a727435c7935b4965bfceb051020ce46 100644 (file)
--- a/x264.c
+++ b/x264.c
 #include "config.h"
 #endif
 
+#ifdef _WIN32
+#include <windows.h>
+#else
+#define SetConsoleTitle(t)
+#endif
+
 uint8_t *mux_buffer = NULL;
 int mux_buffer_size = 0;
 
@@ -771,6 +777,7 @@ static int  Encode( x264_param_t *param, cli_opt_t *opt )
     int64_t i_file;
     int     i_frame_size;
     int     i_update_interval;
+    char    buf[200];
 
     opt->b_progress &= param->i_log_level < X264_LOG_DEBUG;
     i_frame_total = p_get_frame_total( opt->hin );
@@ -827,16 +834,20 @@ static int  Encode( x264_param_t *param, cli_opt_t *opt )
         {
             int64_t i_elapsed = x264_mdate() - i_start;
             double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
+            double bitrate = (double) i_file * 8 * param->i_fps_num / ( (double) param->i_fps_den * i_frame * 1000 );
             if( i_frame_total )
             {
                 int eta = i_elapsed * (i_frame_total - i_frame) / ((int64_t)i_frame * 1000000);
-                fprintf( stderr, "encoded frames: %d/%d (%.1f%%), %.2f fps, %.2f kb/s, eta %d:%02d:%02d  \r",
-                         i_frame, i_frame_total, 100. * i_frame / i_frame_total, fps,
-                         (double) i_file * 8 * param->i_fps_num / ( (double) param->i_fps_den * i_frame * 1000 ),
+                sprintf( buf, "x264 - encoded frames: %d/%d (%.1f%%), %.2f fps, %.2f kb/s, eta %d:%02d:%02d",
+                         i_frame, i_frame_total, 100. * i_frame / i_frame_total, fps, bitrate,
                          eta/3600, (eta/60)%60, eta%60 );
             }
             else
-                fprintf( stderr, "encoded frames: %d, %.2f fps   \r", i_frame, fps );
+            {
+                sprintf( buf, "x264 - encoded frames: %d, %.2f fps, %.2f kb/s", i_frame, fps, bitrate );
+            }
+            fprintf( stderr, "%s  \r", buf+7 );
+            SetConsoleTitle( buf );
             fflush( stderr ); // needed in windows
         }
     }