forked from datarhei/ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FFmpeg-devel-10-13-avformat-flvdec-add-support-for-reading-multi-track-audio.diff
43 lines (41 loc) · 1.7 KB
/
FFmpeg-devel-10-13-avformat-flvdec-add-support-for-reading-multi-track-audio.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 890958351a..5877828c52 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1336,12 +1336,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;
@@ -1438,7 +1452,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 &&