* [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
@ 2025-05-16 14:24 Zhao Zhili
2025-05-16 14:52 ` Timo Rothenpieler
0 siblings, 1 reply; 13+ messages in thread
From: Zhao Zhili @ 2025-05-16 14:24 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
From: Zhao Zhili <zhilizhao@tencent.com>
ffmpeg -i input.mp4 -c copy -tag:v av01 output.flv
[flv @ 0x143204080] Tag av01 incompatible with output codec id '225' (10va)
---
libavformat/flvenc.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index f026f0e53b..e92828b197 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -52,9 +52,9 @@ static const AVCodecTag flv_video_codec_ids[] = {
{ AV_CODEC_ID_VP6, FLV_CODECID_VP6 },
{ AV_CODEC_ID_VP6A, FLV_CODECID_VP6A },
{ AV_CODEC_ID_H264, FLV_CODECID_H264 },
- { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') },
- { AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') },
- { AV_CODEC_ID_VP9, MKBETAG('v', 'p', '0', '9') },
+ { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') },
+ { AV_CODEC_ID_AV1, MKTAG('a', 'v', '0', '1') },
+ { AV_CODEC_ID_VP9, MKTAG('v', 'p', '0', '9') },
{ AV_CODEC_ID_NONE, 0 }
};
@@ -69,10 +69,10 @@ static const AVCodecTag flv_audio_codec_ids[] = {
{ AV_CODEC_ID_PCM_MULAW, FLV_CODECID_PCM_MULAW >> FLV_AUDIO_CODECID_OFFSET },
{ AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET },
{ AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET },
- { AV_CODEC_ID_OPUS, MKBETAG('O', 'p', 'u', 's') },
- { AV_CODEC_ID_FLAC, MKBETAG('f', 'L', 'a', 'C') },
- { AV_CODEC_ID_AC3, MKBETAG('a', 'c', '-', '3') },
- { AV_CODEC_ID_EAC3, MKBETAG('e', 'c', '-', '3') },
+ { AV_CODEC_ID_OPUS, MKTAG('O', 'p', 'u', 's') },
+ { AV_CODEC_ID_FLAC, MKTAG('f', 'L', 'a', 'C') },
+ { AV_CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') },
+ { AV_CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') },
{ AV_CODEC_ID_NONE, 0 }
};
@@ -348,7 +348,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
}
put_amf_string(pb, "videocodecid");
- put_amf_double(pb, flv->video_par->codec_tag);
+ uint32_t tag = flv->video_par->codec_tag;
+ // check and convert to fourcc
+ if (tag & 0xFFFFFF00)
+ tag = av_bswap32(tag);
+ put_amf_double(pb, tag);
}
if (flv->audio_par) {
@@ -365,7 +369,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
put_amf_string(pb, "audiocodecid");
- put_amf_double(pb, flv->audio_par->codec_tag);
+ uint32_t tag = flv->audio_par->codec_tag;
+ // check and convert to fourcc
+ if (tag & 0xFFFFFF00)
+ tag = av_bswap32(tag);
+ put_amf_double(pb, tag);
}
if (flv->data_par) {
--
2.46.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 14:24 [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG Zhao Zhili
@ 2025-05-16 14:52 ` Timo Rothenpieler
2025-05-16 15:59 ` Zhao Zhili
0 siblings, 1 reply; 13+ messages in thread
From: Timo Rothenpieler @ 2025-05-16 14:52 UTC (permalink / raw)
To: ffmpeg-devel
On 16/05/2025 16:24, Zhao Zhili wrote:
> From: Zhao Zhili <zhilizhao@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.
> ---
> libavformat/flvenc.c | 26 +++++++++++++++++---------
> 1 file changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
> index f026f0e53b..e92828b197 100644
> --- a/libavformat/flvenc.c
> +++ b/libavformat/flvenc.c
> @@ -52,9 +52,9 @@ static const AVCodecTag flv_video_codec_ids[] = {
> { AV_CODEC_ID_VP6, FLV_CODECID_VP6 },
> { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A },
> { AV_CODEC_ID_H264, FLV_CODECID_H264 },
> - { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') },
> - { AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') },
> - { AV_CODEC_ID_VP9, MKBETAG('v', 'p', '0', '9') },
> + { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') },
> + { AV_CODEC_ID_AV1, MKTAG('a', 'v', '0', '1') },
> + { AV_CODEC_ID_VP9, MKTAG('v', 'p', '0', '9') },
> { AV_CODEC_ID_NONE, 0 }
> };
>
> @@ -69,10 +69,10 @@ static const AVCodecTag flv_audio_codec_ids[] = {
> { AV_CODEC_ID_PCM_MULAW, FLV_CODECID_PCM_MULAW >> FLV_AUDIO_CODECID_OFFSET },
> { AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET },
> { AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET },
> - { AV_CODEC_ID_OPUS, MKBETAG('O', 'p', 'u', 's') },
> - { AV_CODEC_ID_FLAC, MKBETAG('f', 'L', 'a', 'C') },
> - { AV_CODEC_ID_AC3, MKBETAG('a', 'c', '-', '3') },
> - { AV_CODEC_ID_EAC3, MKBETAG('e', 'c', '-', '3') },
> + { AV_CODEC_ID_OPUS, MKTAG('O', 'p', 'u', 's') },
> + { AV_CODEC_ID_FLAC, MKTAG('f', 'L', 'a', 'C') },
> + { AV_CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') },
> + { AV_CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') },
> { AV_CODEC_ID_NONE, 0 }
> };
>
> @@ -348,7 +348,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
> }
>
> put_amf_string(pb, "videocodecid");
> - put_amf_double(pb, flv->video_par->codec_tag);
> + uint32_t tag = flv->video_par->codec_tag;
> + // check and convert to fourcc
> + if (tag & 0xFFFFFF00)
> + tag = av_bswap32(tag);
> + put_amf_double(pb, tag);
Shouldn't this be completely equivalent to having MKBETAG generate it in
big-endian order from the get-go?
> }
>
> if (flv->audio_par) {
> @@ -365,7 +369,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
> put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
>
> put_amf_string(pb, "audiocodecid");
> - put_amf_double(pb, flv->audio_par->codec_tag);
> + uint32_t tag = flv->audio_par->codec_tag;
> + // check and convert to fourcc
> + if (tag & 0xFFFFFF00)
> + tag = av_bswap32(tag);
> + put_amf_double(pb, tag);
> }
>
> if (flv->data_par) {
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 14:52 ` Timo Rothenpieler
@ 2025-05-16 15:59 ` Zhao Zhili
2025-05-16 16:27 ` Timo Rothenpieler
0 siblings, 1 reply; 13+ messages in thread
From: Zhao Zhili @ 2025-05-16 15:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>
> On 16/05/2025 16:24, Zhao Zhili wrote:
>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>
>> ---
>> libavformat/flvenc.c | 26 +++++++++++++++++---------
>> 1 file changed, 17 insertions(+), 9 deletions(-)
>> diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
>> index f026f0e53b..e92828b197 100644
>> --- a/libavformat/flvenc.c
>> +++ b/libavformat/flvenc.c
>> @@ -52,9 +52,9 @@ static const AVCodecTag flv_video_codec_ids[] = {
>> { AV_CODEC_ID_VP6, FLV_CODECID_VP6 },
>> { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A },
>> { AV_CODEC_ID_H264, FLV_CODECID_H264 },
>> - { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') },
>> - { AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') },
>> - { AV_CODEC_ID_VP9, MKBETAG('v', 'p', '0', '9') },
>> + { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') },
>> + { AV_CODEC_ID_AV1, MKTAG('a', 'v', '0', '1') },
>> + { AV_CODEC_ID_VP9, MKTAG('v', 'p', '0', '9') },
>> { AV_CODEC_ID_NONE, 0 }
>> };
>> @@ -69,10 +69,10 @@ static const AVCodecTag flv_audio_codec_ids[] = {
>> { AV_CODEC_ID_PCM_MULAW, FLV_CODECID_PCM_MULAW >> FLV_AUDIO_CODECID_OFFSET },
>> { AV_CODEC_ID_PCM_ALAW, FLV_CODECID_PCM_ALAW >> FLV_AUDIO_CODECID_OFFSET },
>> { AV_CODEC_ID_SPEEX, FLV_CODECID_SPEEX >> FLV_AUDIO_CODECID_OFFSET },
>> - { AV_CODEC_ID_OPUS, MKBETAG('O', 'p', 'u', 's') },
>> - { AV_CODEC_ID_FLAC, MKBETAG('f', 'L', 'a', 'C') },
>> - { AV_CODEC_ID_AC3, MKBETAG('a', 'c', '-', '3') },
>> - { AV_CODEC_ID_EAC3, MKBETAG('e', 'c', '-', '3') },
>> + { AV_CODEC_ID_OPUS, MKTAG('O', 'p', 'u', 's') },
>> + { AV_CODEC_ID_FLAC, MKTAG('f', 'L', 'a', 'C') },
>> + { AV_CODEC_ID_AC3, MKTAG('a', 'c', '-', '3') },
>> + { AV_CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') },
>> { AV_CODEC_ID_NONE, 0 }
>> };
>> @@ -348,7 +348,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
>> }
>> put_amf_string(pb, "videocodecid");
>> - put_amf_double(pb, flv->video_par->codec_tag);
>> + uint32_t tag = flv->video_par->codec_tag;
>> + // check and convert to fourcc
>> + if (tag & 0xFFFFFF00)
>> + tag = av_bswap32(tag);
>> + put_amf_double(pb, tag);
>
> Shouldn't this be completely equivalent to having MKBETAG generate it in big-endian order from the get-go?
>
>> }
>> if (flv->audio_par) {
>> @@ -365,7 +369,11 @@ static void write_metadata(AVFormatContext *s, unsigned int ts)
>> put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
>> put_amf_string(pb, "audiocodecid");
>> - put_amf_double(pb, flv->audio_par->codec_tag);
>> + uint32_t tag = flv->audio_par->codec_tag;
>> + // check and convert to fourcc
>> + if (tag & 0xFFFFFF00)
>> + tag = av_bswap32(tag);
>> + put_amf_double(pb, tag);
>> }
>> if (flv->data_par) {
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org <mailto:ffmpeg-devel-request@ffmpeg.org> with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 15:59 ` Zhao Zhili
@ 2025-05-16 16:27 ` Timo Rothenpieler
2025-05-16 17:10 ` Zhao Zhili
0 siblings, 1 reply; 13+ messages in thread
From: Timo Rothenpieler @ 2025-05-16 16:27 UTC (permalink / raw)
To: ffmpeg-devel
On 16.05.2025 17:59, Zhao Zhili wrote:
>
>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>
>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 16:27 ` Timo Rothenpieler
@ 2025-05-16 17:10 ` Zhao Zhili
2025-05-16 17:18 ` Zhao Zhili
2025-05-16 17:24 ` Zhao Zhili
0 siblings, 2 replies; 13+ messages in thread
From: Zhao Zhili @ 2025-05-16 17:10 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>
> On 16.05.2025 17:59, Zhao Zhili wrote:
>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>
>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
A user shows the error message to me. Because he know there are -tag option for mp4, and
enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
is the right order of fourcc in spec. The endian issue should be limited to the internal.
Current error message is confusing, because it shows 10va instead of av01.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 17:10 ` Zhao Zhili
@ 2025-05-16 17:18 ` Zhao Zhili
2025-05-16 17:24 ` Zhao Zhili
1 sibling, 0 replies; 13+ messages in thread
From: Zhao Zhili @ 2025-05-16 17:18 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>
>
>
>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>
>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>
>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>
> A user shows the error message to me. Because he know there are -tag option for mp4, and
> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>
> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
> is the right order of fourcc in spec. The endian issue should be limited to the internal.
> Current error message is confusing, because it shows 10va instead of av01.
>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 17:10 ` Zhao Zhili
2025-05-16 17:18 ` Zhao Zhili
@ 2025-05-16 17:24 ` Zhao Zhili
2025-05-16 17:39 ` Timo Rothenpieler
1 sibling, 1 reply; 13+ messages in thread
From: Zhao Zhili @ 2025-05-16 17:24 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>
>
>
>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>
>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>
>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>
> A user shows the error message to me. Because he know there are -tag option for mp4, and
> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>
> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
> is the right order of fourcc in spec. The endian issue should be limited to the internal.
> Current error message is confusing, because it shows 10va instead of av01.
Doc from Microsoft shows fourcc use small endian
https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
While wiki and enhanced rtmp spec says it’s big endian
https://en.wikipedia.org/wiki/FourCC
It’s clear in av_fourcc_make_string
that we use small endian.
For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 17:24 ` Zhao Zhili
@ 2025-05-16 17:39 ` Timo Rothenpieler
2025-05-17 4:35 ` Zhao Zhili
0 siblings, 1 reply; 13+ messages in thread
From: Timo Rothenpieler @ 2025-05-16 17:39 UTC (permalink / raw)
To: ffmpeg-devel
On 16.05.2025 19:24, Zhao Zhili wrote:
>
>
>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>>
>>
>>
>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>
>>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>
>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>>
>> A user shows the error message to me. Because he know there are -tag option for mp4, and
>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>>
>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
>> Current error message is confusing, because it shows 10va instead of av01.
>
> Doc from Microsoft shows fourcc use small endian
> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
>
> While wiki and enhanced rtmp spec says it’s big endian
> https://en.wikipedia.org/wiki/FourCC
>
> It’s clear in av_fourcc_make_string
> that we use small endian.
>
> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
This patch just fixes it for a very small subset of codecs in flv though.
There's nothing indicating that -tag:v is needed or sensibly supported
in flvenc.
If you'd want to pass h264 or aac as fourcc, it'd be flat out
impossible, and no easy fix is available.
I'd rather not complicate flvenc, even if just a little bit, just to
swap around the endianness of the few codecs that do use a fourcc based tag.
flvenv should probably just completely ignore -tag:v, since the option
makes no sense for it anyway.
And maybe print a warning when it's used only.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-16 17:39 ` Timo Rothenpieler
@ 2025-05-17 4:35 ` Zhao Zhili
2025-05-17 11:14 ` Timo Rothenpieler
0 siblings, 1 reply; 13+ messages in thread
From: Zhao Zhili @ 2025-05-17 4:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: ffmpeg-devel
> 在 2025年5月17日,上午1:39,Timo Rothenpieler <timo@rothenpieler.org> 写道:
>
> On 16.05.2025 19:24, Zhao Zhili wrote:
>>>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>>>
>>>
>>>
>>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>
>>>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>
>>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>>>
>>> A user shows the error message to me. Because he know there are -tag option for mp4, and
>>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>>>
>>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
>>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
>>> Current error message is confusing, because it shows 10va instead of av01.
>> Doc from Microsoft shows fourcc use small endian
>> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
>> While wiki and enhanced rtmp spec says it’s big endian
>> https://en.wikipedia.org/wiki/FourCC
>> It’s clear in av_fourcc_make_string
>> that we use small endian.
>> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
>
> This patch just fixes it for a very small subset of codecs in flv though.
> There's nothing indicating that -tag:v is needed or sensibly supported in flvenc.
> If you'd want to pass h264 or aac as fourcc, it'd be flat out impossible, and no easy fix is available.
>
> I'd rather not complicate flvenc, even if just a little bit, just to swap around the endianness of the few codecs that do use a fourcc based tag.
>
> flvenv should probably just completely ignore -tag:v, since the option makes no sense for it anyway.
I can remove setting tag list to AVOutputFormat, does that works for you?
> And maybe print a warning when it's used only.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-17 4:35 ` Zhao Zhili
@ 2025-05-17 11:14 ` Timo Rothenpieler
2025-05-17 14:05 ` Zhao Zhili
0 siblings, 1 reply; 13+ messages in thread
From: Timo Rothenpieler @ 2025-05-17 11:14 UTC (permalink / raw)
To: ffmpeg-devel
On 17.05.2025 06:35, Zhao Zhili wrote:
>
>> 在 2025年5月17日,上午1:39,Timo Rothenpieler <timo@rothenpieler.org> 写道:
>>
>> On 16.05.2025 19:24, Zhao Zhili wrote:
>>>>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>>>>
>>>>
>>>>
>>>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>
>>>>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>>
>>>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>>>>
>>>> A user shows the error message to me. Because he know there are -tag option for mp4, and
>>>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>>>>
>>>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
>>>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
>>>> Current error message is confusing, because it shows 10va instead of av01.
>>> Doc from Microsoft shows fourcc use small endian
>>> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
>>> While wiki and enhanced rtmp spec says it’s big endian
>>> https://en.wikipedia.org/wiki/FourCC
>>> It’s clear in av_fourcc_make_string
>>> that we use small endian.
>>> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
>>
>> This patch just fixes it for a very small subset of codecs in flv though.
>> There's nothing indicating that -tag:v is needed or sensibly supported in flvenc.
>> If you'd want to pass h264 or aac as fourcc, it'd be flat out impossible, and no easy fix is available.
>>
>> I'd rather not complicate flvenc, even if just a little bit, just to swap around the endianness of the few codecs that do use a fourcc based tag.
>>
>> flvenv should probably just completely ignore -tag:v, since the option makes no sense for it anyway.
>
> I can remove setting tag list to AVOutputFormat, does that works for you?
Won't that break even more things?
The code heavily relies on the tags being what they are, and passing the
tag list to AVOutputFormat would remove avformat enforcing that, with
said error when trying to override it with something invalid.
I honestly don't think anything needs to be changed at all.
Passing custom tags is simply not something flv sensibly supports.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-17 11:14 ` Timo Rothenpieler
@ 2025-05-17 14:05 ` Zhao Zhili
2025-05-17 15:43 ` Timo Rothenpieler
2025-05-17 23:38 ` Michael Niedermayer
0 siblings, 2 replies; 13+ messages in thread
From: Zhao Zhili @ 2025-05-17 14:05 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Michael Niedermayer
> On May 17, 2025, at 19:14, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>
> On 17.05.2025 06:35, Zhao Zhili wrote:
>>> 在 2025年5月17日,上午1:39,Timo Rothenpieler <timo@rothenpieler.org> 写道:
>>>
>>> On 16.05.2025 19:24, Zhao Zhili wrote:
>>>>>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>
>>>>>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>>>
>>>>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>>>>>
>>>>> A user shows the error message to me. Because he know there are -tag option for mp4, and
>>>>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>>>>>
>>>>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
>>>>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
>>>>> Current error message is confusing, because it shows 10va instead of av01.
>>>> Doc from Microsoft shows fourcc use small endian
>>>> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
>>>> While wiki and enhanced rtmp spec says it’s big endian
>>>> https://en.wikipedia.org/wiki/FourCC
>>>> It’s clear in av_fourcc_make_string
>>>> that we use small endian.
>>>> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
>>>
>>> This patch just fixes it for a very small subset of codecs in flv though.
>>> There's nothing indicating that -tag:v is needed or sensibly supported in flvenc.
>>> If you'd want to pass h264 or aac as fourcc, it'd be flat out impossible, and no easy fix is available.
>>>
>>> I'd rather not complicate flvenc, even if just a little bit, just to swap around the endianness of the few codecs that do use a fourcc based tag.
>>>
>>> flvenv should probably just completely ignore -tag:v, since the option makes no sense for it anyway.
>> I can remove setting tag list to AVOutputFormat, does that works for you?
>
> Won't that break even more things?
> The code heavily relies on the tags being what they are, and passing the tag list to AVOutputFormat would remove avformat enforcing that, with said error when trying to override it with something invalid.
The enforcing logic has a precondition, that codec_tag is in little endian.
flv_video_codec_ids and flv_audio_codec_ids don’t match this requirement.
>
> I honestly don't think anything needs to be changed at all.
> Passing custom tags is simply not something flv sensibly supports.
AVOutputFormat codec_tag is API exported to users. Even if users
are not supposed to pass codec_tag to flvenc, the exported information
should match the tradition, that codec_tag is in little endian according to
the code in av_fourcc_make_string, mov, matroska, and so on.
There is no explicit documentation on the endian issue of codec_tag.
I hope developers familiar with the history can share insights on this topic.
Cc Michael.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-17 14:05 ` Zhao Zhili
@ 2025-05-17 15:43 ` Timo Rothenpieler
2025-05-17 23:38 ` Michael Niedermayer
1 sibling, 0 replies; 13+ messages in thread
From: Timo Rothenpieler @ 2025-05-17 15:43 UTC (permalink / raw)
To: ffmpeg-devel
On 17.05.2025 16:05, Zhao Zhili wrote:
>
>
>> On May 17, 2025, at 19:14, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>
>> On 17.05.2025 06:35, Zhao Zhili wrote:
>>>> 在 2025年5月17日,上午1:39,Timo Rothenpieler <timo@rothenpieler.org> 写道:
>>>>
>>>> On 16.05.2025 19:24, Zhao Zhili wrote:
>>>>>>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>>
>>>>>>> On 16.05.2025 17:59, Zhao Zhili wrote:
>>>>>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
>>>>>>>>>
>>>>>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
>>>>>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
>>>>>>
>>>>>> A user shows the error message to me. Because he know there are -tag option for mp4, and
>>>>>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
>>>>>>
>>>>>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
>>>>>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
>>>>>> Current error message is confusing, because it shows 10va instead of av01.
>>>>> Doc from Microsoft shows fourcc use small endian
>>>>> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
>>>>> While wiki and enhanced rtmp spec says it’s big endian
>>>>> https://en.wikipedia.org/wiki/FourCC
>>>>> It’s clear in av_fourcc_make_string
>>>>> that we use small endian.
>>>>> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
>>>>
>>>> This patch just fixes it for a very small subset of codecs in flv though.
>>>> There's nothing indicating that -tag:v is needed or sensibly supported in flvenc.
>>>> If you'd want to pass h264 or aac as fourcc, it'd be flat out impossible, and no easy fix is available.
>>>>
>>>> I'd rather not complicate flvenc, even if just a little bit, just to swap around the endianness of the few codecs that do use a fourcc based tag.
>>>>
>>>> flvenv should probably just completely ignore -tag:v, since the option makes no sense for it anyway.
>>> I can remove setting tag list to AVOutputFormat, does that works for you?
>>
>> Won't that break even more things?
>> The code heavily relies on the tags being what they are, and passing the tag list to AVOutputFormat would remove avformat enforcing that, with said error when trying to override it with something invalid.
>
> The enforcing logic has a precondition, that codec_tag is in little endian.
> flv_video_codec_ids and flv_audio_codec_ids don’t match this requirement.
That's not true, it correctly enforces it to what's in the tag array.
It makes sure that for each codec in there, the tag can only be one
that's listed.
>>
>> I honestly don't think anything needs to be changed at all.
>> Passing custom tags is simply not something flv sensibly supports.
>
> AVOutputFormat codec_tag is API exported to users. Even if users
> are not supposed to pass codec_tag to flvenc, the exported information
> should match the tradition, that codec_tag is in little endian according to
> the code in av_fourcc_make_string, mov, matroska, and so on.
Only a very small handful of codecs in flv even use a human-readable
tag, the others are just arbitrary numbers.
I really don't understand why it'd matter if those are in big or little
endian order. They cannot be changed, passing the via -tag:v achieves
nothing.
Not a single codec flv can write has an alternative tag available to it.
> There is no explicit documentation on the endian issue of codec_tag.
> I hope developers familiar with the history can share insights on this topic.
> Cc Michael.
There is no explicit documentation on what a codec_tag is in general,
since it's highly container specific.
In case of flv, it's either arbitrary numbers, or big endian fourcc
values for _some_ codecs.
I still see no issue with that, you simply cannot pass "-tag:v av01" to
flvenc, just like you can't pass "-tag:v h264" or hevc/hvc1/..., since
those tags are not valid tags for flv.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG
2025-05-17 14:05 ` Zhao Zhili
2025-05-17 15:43 ` Timo Rothenpieler
@ 2025-05-17 23:38 ` Michael Niedermayer
1 sibling, 0 replies; 13+ messages in thread
From: Michael Niedermayer @ 2025-05-17 23:38 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 6411 bytes --]
Hi Zhao Zhili
On Sat, May 17, 2025 at 10:05:34PM +0800, Zhao Zhili wrote:
>
>
> > On May 17, 2025, at 19:14, Timo Rothenpieler <timo@rothenpieler.org> wrote:
> >
> > On 17.05.2025 06:35, Zhao Zhili wrote:
> >>> 在 2025年5月17日,上午1:39,Timo Rothenpieler <timo@rothenpieler.org> 写道:
> >>>
> >>> On 16.05.2025 19:24, Zhao Zhili wrote:
> >>>>>> On May 17, 2025, at 01:10, Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>> On May 17, 2025, at 00:27, Timo Rothenpieler <timo@rothenpieler.org> wrote:
> >>>>>>
> >>>>>> On 16.05.2025 17:59, Zhao Zhili wrote:
> >>>>>>>> On May 16, 2025, at 22:52, Timo Rothenpieler <timo@rothenpieler.org> wrote:
> >>>>>>>>
> >>>>>>>> On 16/05/2025 16:24, Zhao Zhili wrote:
> >>>>>>>>> From: Zhao Zhili <zhilizhao@tencent.com <mailto:zhilizhao@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.
> >>>>>
> >>>>> A user shows the error message to me. Because he know there are -tag option for mp4, and
> >>>>> enhanced-rtmp use fourcc for extended codecs, so he thought it should work.
> >>>>>
> >>>>> The -tag:v av01 is redundant, it should be a NOP, not trigger error. The strings “av01”
> >>>>> is the right order of fourcc in spec. The endian issue should be limited to the internal.
> >>>>> Current error message is confusing, because it shows 10va instead of av01.
> >>>> Doc from Microsoft shows fourcc use small endian
> >>>> https://learn.microsoft.com/en-us/windows/win32/directshow/fourcc-codes
> >>>> While wiki and enhanced rtmp spec says it’s big endian
> >>>> https://en.wikipedia.org/wiki/FourCC
> >>>> It’s clear in av_fourcc_make_string
> >>>> that we use small endian.
> >>>> For normal codec id in flv, e.g, 7 for H.264, it’s not a big issue, since they’re not fourcc.
> >>>
> >>> This patch just fixes it for a very small subset of codecs in flv though.
> >>> There's nothing indicating that -tag:v is needed or sensibly supported in flvenc.
> >>> If you'd want to pass h264 or aac as fourcc, it'd be flat out impossible, and no easy fix is available.
> >>>
> >>> I'd rather not complicate flvenc, even if just a little bit, just to swap around the endianness of the few codecs that do use a fourcc based tag.
> >>>
> >>> flvenv should probably just completely ignore -tag:v, since the option makes no sense for it anyway.
> >> I can remove setting tag list to AVOutputFormat, does that works for you?
> >
> > Won't that break even more things?
> > The code heavily relies on the tags being what they are, and passing the tag list to AVOutputFormat would remove avformat enforcing that, with said error when trying to override it with something invalid.
>
> The enforcing logic has a precondition, that codec_tag is in little endian.
> flv_video_codec_ids and flv_audio_codec_ids don’t match this requirement.
>
> >
> > I honestly don't think anything needs to be changed at all.
> > Passing custom tags is simply not something flv sensibly supports.
>
> AVOutputFormat codec_tag is API exported to users. Even if users
> are not supposed to pass codec_tag to flvenc, the exported information
> should match the tradition, that codec_tag is in little endian according to
> the code in av_fourcc_make_string, mov, matroska, and so on.
You are correct but the code did use the opposit endianness for a long
time.
Changing this would need a api version bump,
should be documented in APIChanges
we would have to make sure nothing breaks
In the end iam not sure the work is worth given this seems not
really affecting anything except an error message for a case that isnt
really usefull.
That said, codec_tag is container specific, but it also often has
large numbers of values shared between containers.
If for example mov had a codec_tag that would match one in flv then
having endianness matching between the 2 would be nice
OTOH if flv is its own universe, iam not sure the work to change
endianness is worth the work.
But if someone wants to do that "cleanup" work, iam not against
it, assuming we dont cause others some headaches with it
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-05-17 23:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-16 14:24 [FFmpeg-devel] [PATCH] avformat/flvenc: Specify codec tag with MKTAG Zhao Zhili
2025-05-16 14:52 ` Timo Rothenpieler
2025-05-16 15:59 ` Zhao Zhili
2025-05-16 16:27 ` Timo Rothenpieler
2025-05-16 17:10 ` Zhao Zhili
2025-05-16 17:18 ` Zhao Zhili
2025-05-16 17:24 ` Zhao Zhili
2025-05-16 17:39 ` Timo Rothenpieler
2025-05-17 4:35 ` Zhao Zhili
2025-05-17 11:14 ` Timo Rothenpieler
2025-05-17 14:05 ` Zhao Zhili
2025-05-17 15:43 ` Timo Rothenpieler
2025-05-17 23:38 ` Michael Niedermayer
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git