]> git.sesse.net Git - ffmpeg/commitdiff
avconv: fix -frames for video
authorAnton Khirnov <anton@khirnov.net>
Sun, 27 Mar 2016 12:25:31 +0000 (14:25 +0200)
committerAnton Khirnov <anton@khirnov.net>
Wed, 30 Mar 2016 07:13:09 +0000 (09:13 +0200)
For video, frame_number tracks the number of frames sent to the encoder.
So it should be incremented when we submit a frame, not when we get a
packet back.

avconv.c

index 07c81fa2ad0a33361db27916a06d7f3a4c2fbd16..2e199e36234663d7f94a052ce61677db9cead199 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -537,6 +537,12 @@ static void do_video_out(AVFormatContext *s,
     if (ret < 0)
         goto error;
 
+    /*
+     * For video, there may be reordering, so we can't throw away frames on
+     * encoder flush, we need to limit them here, before they go into encoder.
+     */
+    ost->frame_number++;
+
     while (1) {
         ret = avcodec_receive_packet(enc, &pkt);
         if (ret == AVERROR(EAGAIN))
@@ -554,12 +560,6 @@ static void do_video_out(AVFormatContext *s,
         }
 
         ost->sync_opts++;
-        /*
-        * For video, number of frames in == number of packets out.
-        * But there may be reordering, so we can't throw away frames on encoder
-        * flush, we need to limit them here, before they go into encoder.
-        */
-        ost->frame_number++;
     }
 
     return;