[FFmpeg-devel] [PATCH v2 5/8] ffmpeg: move flushing the queued frames to configure_filtergraph()

wm4 nfxjfg at googlemail.com
Wed Feb 15 11:24:20 EET 2017


From: Anton Khirnov <anton at khirnov.net>

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 at googlemail.com>
---
 ffmpeg.c        | 11 -----------
 ffmpeg_filter.c | 11 +++++++++++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 5ef4eee7ad..83088e5195 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2182,17 +2182,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);
diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index f21a8c85f8..4d9a4e2eb8 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -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;
 }
 
-- 
2.11.0



More information about the ffmpeg-devel mailing list