diff mbox series

[FFmpeg-devel,12/27] fftools/ffmpeg_filter: fail on filtering errors

Message ID 20230919191044.18873-13-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/27] fftools/ffmpeg: move derivation of frame duration from filter framerate | expand

Commit Message

Anton Khirnov Sept. 19, 2023, 7:10 p.m. UTC
These should be considered serious errors - don't just print a log
message and continue as if nothing happened.
---
 fftools/ffmpeg_filter.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 92f6a6236d..b9a4a4e400 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2152,17 +2152,17 @@  static int fg_output_step(OutputFilterPriv *ofp, int flush)
 
     ret = av_buffersink_get_frame_flags(filter, frame,
                                         AV_BUFFERSINK_FLAG_NO_REQUEST);
-    if (ret < 0) {
-        if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
-            av_log(fgp, AV_LOG_WARNING,
-                   "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret));
-        } else if (flush && ret == AVERROR_EOF && ofp->got_frame &&
-                   av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO) {
-            ret = fg_output_frame(ofp, NULL);
-            return (ret < 0) ? ret : 1;
-        }
-
+    if (flush && ret == AVERROR_EOF && ofp->got_frame &&
+        ost->type == AVMEDIA_TYPE_VIDEO) {
+        ret = fg_output_frame(ofp, NULL);
+        return (ret < 0) ? ret : 1;
+    } else if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
         return 1;
+    } else if (ret < 0) {
+        av_log(fgp, AV_LOG_WARNING,
+               "Error in retrieving a frame from the filtergraph: %s\n",
+               av_err2str(ret));
+        return ret;
     }
     if (ost->finished) {
         av_frame_unref(frame);