]> git.sesse.net Git - x264/commitdiff
cli: fix a crash on piped input.
authorLoren Merritt <pengvado@videolan.org>
Sun, 2 Oct 2005 05:50:35 +0000 (05:50 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sun, 2 Oct 2005 05:50:35 +0000 (05:50 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@311 df754926-b1dd-0310-bc7b-ec298dee348c

x264.c

diff --git a/x264.c b/x264.c
index a6b663817fa5b6450979e15eb6771f6496fa76b3..b1fdc4c0b0813547b68bcda07e31b4e2788977d2 100644 (file)
--- a/x264.c
+++ b/x264.c
@@ -1136,13 +1136,19 @@ static int  Encode( x264_param_t *param, cli_opt_t *opt )
 
         /* update status line (up to 1000 times per input file) */
         if( opt->b_progress && param->i_log_level < X264_LOG_DEBUG && 
-            i_frame * 1000 / i_frame_total > i_progress )
+            ( i_frame_total ? i_frame * 1000 / i_frame_total > i_progress
+                            : i_frame % 10 == 0 ) )
         {
             int64_t i_elapsed = x264_mdate() - i_start;
             double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
-            i_progress = i_frame * 1000 / i_frame_total;
-            fprintf( stderr, "encoded frames: %d/%d (%.1f%%), %.2f fps   \r", i_frame,
-                     i_frame_total, (float)i_progress / 10, fps );
+            if( i_frame_total )
+            {
+                i_progress = i_frame * 1000 / i_frame_total;
+                fprintf( stderr, "encoded frames: %d/%d (%.1f%%), %.2f fps   \r", i_frame,
+                         i_frame_total, (float)i_progress / 10, fps );
+            }
+            else
+                fprintf( stderr, "encoded frames: %d, %.2f fps   \r", i_frame, fps );
             fflush( stderr ); // needed in windows
         }
     }