diff mbox series

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

Message ID 20200911161107.24870-5-jeebjp@gmail.com
State New
Headers show
Series ffmpeg: late A/V encoder init, AVFrame metadata usage
Related show

Checks

Context Check Description
andriy/default pending

Commit Message

Jan Ekström Sept. 11, 2020, 4:11 p.m. UTC
This should make it easier to spot such cases.
---
 fftools/ffmpeg.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

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