diff mbox series

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

Message ID 1591606685-4450-2-git-send-email-linjie.fu@intel.com
State New
Headers show
Series [FFmpeg-devel,1/3] lavc/avcodec: Add caps for the support of variable dimension encoding | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Fu, Linjie June 8, 2020, 8:58 a.m. UTC
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@intel.com>
---
 fftools/ffmpeg.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

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];