[FFmpeg-devel] [PATCH 2/2] ffmpeg: handling copyts use case in progress report computation

vdixit at akamai.com vdixit at akamai.com
Thu Apr 26 08:04:00 EEST 2018


From: Vishwanath Dixit <vdixit at akamai.com>

Progress report computation functionality was assuming the first
PTS value to be zero, but, when 'copyts' is enalbed, the first PTS
can be any big number. This was eventually causing display of
weird statistics during execution of an ffmpeg command. To overcome
this issue, the actual first PTS value has to be considered.
---
 fftools/ffmpeg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d9bb78a..9b71525 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1646,7 +1646,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
     int frame_number, vid, i;
     double bitrate;
     double speed;
-    int64_t pts = INT64_MIN + 1;
+    int64_t pts = INT64_MIN + 1, first_pts = INT64_MAX;
     static int64_t last_time = -1;
     static int qp_histogram[52];
     int hours, mins, secs, us;
@@ -1744,6 +1744,11 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
             }
             vid = 1;
         }
+
+        /* Find the first written PTS among all the output streams */
+        first_pts = FFMIN(first_pts, av_rescale_q(ost->first_pts,
+                                                  ost->enc_ctx->time_base,
+                                                  AV_TIME_BASE_Q));
         /* compute min output value */
         if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE)
             pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st),
@@ -1752,6 +1757,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
             nb_frames_drop += ost->last_dropped;
     }
 
+    pts -= first_pts;
     secs = FFABS(pts) / AV_TIME_BASE;
     us = FFABS(pts) % AV_TIME_BASE;
     mins = secs / 60;
-- 
1.9.1



More information about the ffmpeg-devel mailing list