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

Linjie Fu linjie.fu at intel.com
Mon Jun 8 11:58:04 EEST 2020


This ensures that an encoder is able to cope with input frames
with resolution changing 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 2e9448e..5859781 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1056,6 +1056,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