[FFmpeg-devel] [PATCH] avoid floating point for -t endtime

Reimar Döffinger Reimar.Doeffinger
Sat Feb 6 14:38:27 CET 2010


Hello,
currently the roqvideo FATE test produces different results because of this.
While the test needs to be changed anyway, patch below makes them give identical
results.
The calculation is not 100% exact since I can't multiply recording_time with
anything to avoid an overflow (actually I am not sure about the av_mul_q of
time_base and pts either).
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 21654)
+++ ffmpeg.c	(working copy)
@@ -2195,6 +2195,7 @@
     timer_start = av_gettime();
 
     for(; received_sigterm == 0;) {
+        AVRational cur_time;
         int file_index, ist_index;
         AVPacket pkt;
         double ipts_min;
@@ -2318,7 +2319,8 @@
         }
 
         /* finish if recording time exhausted */
-        if (pkt.pts * av_q2d(ist->st->time_base) >= (recording_time / 1000000.0))
+        cur_time = av_mul_q((AVRational){pkt.pts, 1}, ist->st->time_base);
+        if (cur_time.num * 1000000 / cur_time.den >= recording_time)
             goto discard_packet;
 
         //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size);




More information about the ffmpeg-devel mailing list