[FFmpeg-devel] [PATCH v3 10/16] avformat/flvdec: add support for reading multi track audio
Timo Rothenpieler
timo at rothenpieler.org
Fri Dec 20 02:43:47 EET 2024
---
libavformat/flvdec.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index fbc8bc9d32..15312cfa02 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1338,12 +1338,26 @@ retry:
pkt_type = flags & ~FLV_AUDIO_CODECID_MASK;
if (pkt_type == AudioPacketTypeMultitrack) {
- av_log(s, AV_LOG_ERROR, "Multitrack audio is unsupported!\n");
- return AVERROR_PATCHWELCOME;
+ uint8_t types = avio_r8(s->pb);
+ int multitrack_type = types >> 4;
+ pkt_type = types & 0xF;
+
+ if (multitrack_type != MultitrackTypeOneTrack) {
+ av_log(s, AV_LOG_ERROR, "Audio multitrack types other than MultitrackTypeOneTrack are unsupported!\n");
+ return AVERROR_PATCHWELCOME;
+ }
+
+ multitrack = 1;
+ size--;
}
codec_id = avio_rb32(s->pb);
size -= 4;
+
+ if (multitrack) {
+ track_idx = avio_r8(s->pb);
+ size--;
+ }
}
} else if (type == FLV_TAG_TYPE_VIDEO) {
stream_type = FLV_STREAM_TYPE_VIDEO;
@@ -1440,7 +1454,8 @@ skip:
st = s->streams[i];
if (stream_type == FLV_STREAM_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
- (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags, codec_id)))
+ (s->audio_codec_id || flv_same_audio_codec(st->codecpar, flags, codec_id)) &&
+ st->id == track_idx)
break;
} else if (stream_type == FLV_STREAM_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
--
2.45.2
More information about the ffmpeg-devel
mailing list