[FFmpeg-devel] [PATCH 4/4] ffmpeg: warn if an encoder has to be initialized without an AVFrame

Jan Ekström jeebjp at gmail.com
Fri Sep 11 19:11:07 EEST 2020


This should make it easier to spot such cases.
---
 fftools/ffmpeg.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 63c8771a01..70e7274d87 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3281,6 +3281,20 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
     AVFormatContext *oc = output_files[ost->file_index]->ctx;
     int j, ret;
 
+    if ((enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
+         enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
+        !frame) {
+        const AVCodecDescriptor *description = \
+            avcodec_descriptor_get(ost->enc_ctx->codec_id);
+
+        av_log(NULL, AV_LOG_WARNING,
+               "Initializing %s output stream %d:%d (%s) without an available "
+               "AVFrame! Possibility of less accurate configuration!\n",
+               av_get_media_type_string(enc_ctx->codec_type),
+               ost->file_index, ost->index,
+               description ? description->name : "no encoder");
+    }
+
     set_encoder_id(output_files[ost->file_index], ost);
 
     // Muxers use AV_PKT_DATA_DISPLAYMATRIX to signal rotation. On the other
-- 
2.26.2



More information about the ffmpeg-devel mailing list