diff mbox series

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

Message ID 1582820043-22426-1-git-send-email-linjie.fu@intel.com
State New
Headers show
Series [FFmpeg-devel,1/3] lavc/avcodec.h: fix missing line breaks in API documentation | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Fu, Linjie Feb. 27, 2020, 4:14 p.m. UTC
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@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 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];