[FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG

Timo Rothenpieler timo at rothenpieler.org
Fri May 16 19:27:12 EEST 2025


On 16.05.2025 17:59, Zhao Zhili wrote:
> 
>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo at rothenpieler.org> wrote:
>>
>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>> From: Zhao Zhili <zhilizhao at tencent.com <mailto:zhilizhao at tencent.com>>
>>> ffmpeg -i input.mp4 -c copy -tag:v av01 output.flv
>>> [flv @ 0x143204080] Tag av01 incompatible with output codec id '225' (10va)
>>
>> I don't quite understand what causes this.
>> Is this an issue when running on big endian architectures?
>> I'm pretty sure I tested all combinations of codecs with muxing and demuxing, and never ran into that error.
> 
> The key point is when specify tag via command line, e.g., -tag:v av01, it’s
> passed to AVCodecParameters codec_tag in little endian.
> 
> You didn’t see the error because without specify the tag explicitly, codec_tag is copied
> from AVOutputFormat codec_tag to AVCodecParameters codec_tag, so they are
> the same.
> 
> Another example is codec_mp4_tags.

This still irks me as wrong.
There is _a lot_ of places all over flvenv.c, in all kinds of functions, 
that hard-depend on the values in par->codec_tag being from the 
_codec_ids tables at the top of the file.
Like, they contain flv specific audio and video codec IDs for the 
pre-ext-flv codecs, those would all also break.

So there seems to be a deeper issue there if those values can be 
overridden from the commandline. The encoder clearly does not expect that.

Looking at the code this error comes from:
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/mux.c#L314

It looks to to me like it's working exactly as intended and required by 
flvenc, protecting it from invalid tags.

So, when the user provides a custom tag that is invalid, isn't that 
kinda on the user?
The check you're running into does what it's supposed to:
It detects that the provided tag is invalid for this codec in this 
container.

Why do you want to override it anyway? There is only exactly one valid 
tag for each codec.


More information about the ffmpeg-devel mailing list