From 643c699f2684987db6073ebe8a6ea76e56c87055 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Tue, 25 May 2021 00:48:40 +0300 Subject: recorder: clear codec_tag if no target format support Avoiding blindly copying the codec_tag between different formats allows us to mux packets from, say, mpegts streams to matroska, making the recorder (dump-cache) much more usable as unsupported codec_tags can make the muxer reject the streams. --- common/recorder.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/recorder.c b/common/recorder.c index 58bf257883..63e4163303 100644 --- a/common/recorder.c +++ b/common/recorder.c @@ -91,6 +91,12 @@ static int add_stream(struct mp_recorder *priv, struct sh_stream *sh) if (!avp) return -1; + // Check if we get the same codec_tag for the output format; + // otherwise clear it to have a chance at muxing + if (av_codec_get_id(priv->mux->oformat->codec_tag, + avp->codec_tag) != avp->codec_tag) + avp->codec_tag = 0; + // We don't know the delay, so make something up. If the format requires // DTS, the result will probably be broken. FFmpeg provides nothing better // yet (unless you demux with libavformat, which contains tons of hacks -- cgit v1.2.3