You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/flvenc: prevent writing legacy codecs into extended video tracks
This commit is contained in:
@@ -970,6 +970,15 @@ static int flv_init(struct AVFormatContext *s)
|
|||||||
|
|
||||||
switch (par->codec_type) {
|
switch (par->codec_type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
|
if (video_ctr &&
|
||||||
|
par->codec_id != AV_CODEC_ID_VP8 &&
|
||||||
|
par->codec_id != AV_CODEC_ID_VP9 &&
|
||||||
|
par->codec_id != AV_CODEC_ID_AV1 &&
|
||||||
|
par->codec_id != AV_CODEC_ID_H264 &&
|
||||||
|
par->codec_id != AV_CODEC_ID_HEVC) {
|
||||||
|
av_log(s, AV_LOG_ERROR, "Unsupported multi-track video codec.\n");
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
if (s->streams[i]->avg_frame_rate.den &&
|
if (s->streams[i]->avg_frame_rate.den &&
|
||||||
s->streams[i]->avg_frame_rate.num) {
|
s->streams[i]->avg_frame_rate.num) {
|
||||||
flv->framerate = av_q2d(s->streams[i]->avg_frame_rate);
|
flv->framerate = av_q2d(s->streams[i]->avg_frame_rate);
|
||||||
@@ -1012,7 +1021,7 @@ static int flv_init(struct AVFormatContext *s)
|
|||||||
par->codec_id != AV_CODEC_ID_FLAC &&
|
par->codec_id != AV_CODEC_ID_FLAC &&
|
||||||
par->codec_id != AV_CODEC_ID_AC3 &&
|
par->codec_id != AV_CODEC_ID_AC3 &&
|
||||||
par->codec_id != AV_CODEC_ID_EAC3) {
|
par->codec_id != AV_CODEC_ID_EAC3) {
|
||||||
av_log(s, AV_LOG_ERROR, "Unsupported multi-track codec.\n");
|
av_log(s, AV_LOG_ERROR, "Unsupported multi-track audio codec.\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
flv->track_idx_map[i] = audio_ctr++;
|
flv->track_idx_map[i] = audio_ctr++;
|
||||||
@@ -1390,6 +1399,10 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
write_codec_fourcc(pb, par->codec_id);
|
write_codec_fourcc(pb, par->codec_id);
|
||||||
if (track_idx)
|
if (track_idx)
|
||||||
avio_w8(pb, track_idx);
|
avio_w8(pb, track_idx);
|
||||||
|
} else if (track_idx) {
|
||||||
|
av_log(s, AV_LOG_ERROR, "Attempted to write legacy codec into extended flv track.\n");
|
||||||
|
ret = AVERROR(EINVAL);
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
av_assert1(flags >= 0);
|
av_assert1(flags >= 0);
|
||||||
avio_w8(pb, flags);
|
avio_w8(pb, flags);
|
||||||
|
Reference in New Issue
Block a user