[FFmpeg-devel] [PATCH 3/3] fftools/ffmpeg: check caps of encoders for encoding frame with variable dimension

Linjie Fu linjie.fu at intel.com
Thu Feb 27 18:14:03 EET 2020


This ensures that an encoder is able to cope with input frames with changing
resolution only if it declares the capability of AV_CODEC_CAP_VARIABLE_DIMENSIONS.

Signed-off-by: Linjie Fu <linjie.fu at intel.com>
---
 fftools/ffmpeg.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index e5fbd47..5c4cf03 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1068,6 +1068,15 @@ static void do_video_out(OutputFile *of,
     InputStream *ist = NULL;
     AVFilterContext *filter = ost->filter->filter;
 
+    if (next_picture && (enc->width != next_picture->width ||
+                         enc->height != next_picture->height)) {
+        if (!(enc->codec->capabilities & AV_CODEC_CAP_VARIABLE_DIMENSIONS)) {
+            av_log(NULL, AV_LOG_ERROR, "Variable dimension encoding "
+                            "is not supported by %s.\n", enc->codec->name);
+            goto error;
+        }
+    }
+
     if (ost->source_index >= 0)
         ist = input_streams[ost->source_index];
 
-- 
2.7.4



More information about the ffmpeg-devel mailing list