ffmpeg: move flushing the queued frames to configure_filtergraph()
authorAnton Khirnov <anton@khirnov.net>
Mon, 27 Jun 2016 16:59:23 +0000 (18:59 +0200)
committerwm4 <nfxjfg@googlemail.com>
Fri, 3 Mar 2017 07:45:43 +0000 (08:45 +0100)
This is a more appropriate place for it, and will also be useful in the
following commit.

This merges Libav commit d2e56cf. It was previously skipped.

Signed-off-by: wm4 <nfxjfg@googlemail.com>
ffmpeg.c
ffmpeg_filter.c

index 88f6834..f52d3e2 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2186,17 +2186,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
             av_log(NULL, AV_LOG_ERROR, "Error reinitializing filters!\n");
             return ret;
         }
-
-        for (i = 0; i < fg->nb_inputs; i++) {
-            while (av_fifo_size(fg->inputs[i]->frame_queue)) {
-                AVFrame *tmp;
-                av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
-                ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
-                av_frame_free(&tmp);
-                if (ret < 0)
-                    return ret;
-            }
-        }
     }
 
     ret = av_buffersrc_add_frame_flags(ifilter->filter, frame, AV_BUFFERSRC_FLAG_PUSH);
index f21a8c8..4d9a4e2 100644 (file)
@@ -1117,6 +1117,17 @@ int configure_filtergraph(FilterGraph *fg)
                                          ost->enc_ctx->frame_size);
     }
 
+    for (i = 0; i < fg->nb_inputs; i++) {
+        while (av_fifo_size(fg->inputs[i]->frame_queue)) {
+            AVFrame *tmp;
+            av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
+            ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
+            av_frame_free(&tmp);
+            if (ret < 0)
+                return ret;
+        }
+    }
+
     return 0;
 }