diff mbox series

[FFmpeg-devel,5/5] avformat/fifo: unset codec tag if unsupported by underlying muxer

Message ID 20201207100845.17520-6-jeebjp@gmail.com
State New
Headers show
Series FIFO meta muxer related improvements
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Jan Ekström Dec. 7, 2020, 10:08 a.m. UTC
From: Jan Ekström <jan.ekstrom@24i.com>

The API client has no visibility into the values provided by the
underlying muxer, so we either do this always, or when an option
is presented.

In this case, we do it unconditionally, as this is probably more
useful.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
---
 libavformat/fifo.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index bc363e458cd..c9b782c2309 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -513,6 +513,18 @@  static int fifo_mux_init(AVFormatContext *avf, ff_const59 AVOutputFormat *oforma
         ret = ff_stream_encode_params_copy(st, avf->streams[i]);
         if (ret < 0)
             return ret;
+
+        if ((st->codecpar->codec_tag && oformat->codec_tag) &&
+            av_codec_get_id(oformat->codec_tag, st->codecpar->codec_tag) != st->codecpar->codec_id) {
+            av_log(avf, AV_LOG_ERROR,
+                   "Codec tag '%s' is unsupported for codec %s in the %s muxer! "
+                   "Unsetting codec tag so that auto-configuration can be "
+                   "attempted.\n",
+                   av_fourcc2str(st->codecpar->codec_tag),
+                   avcodec_get_name(st->codecpar->codec_id),
+                   avf2->oformat->name);
+            st->codecpar->codec_tag = 0;
+        }
     }
 
     return 0;