我正在研究一个mp4容器解析器,但是我疯狂地试图识别流的音频编解码器.我使用了QtAtomViewer和AtomicParsley,但是当我找到原子时:
trak-> mdia-> minf-> stbl-> STSD
即使mp4文件有mp3流,我也总是"mp4a".
我应该找一个".mp3"fourcc吗?
我附加了两个不同的mp4结构:带有AAC音频流的mp4容器
Atom trak @ 716882 of size: 2960, ends @ 719842
Atom tkhd @ 716890 of size: 92, ends @ 716982
Atom mdia @ 716982 of size: 2860, ends @ 719842
Atom mdhd @ 716990 of size: 32, ends @ 717022
Atom hdlr @ 717022 of size: 33, ends @ 717055
Atom minf @ 717055 of size: 2787, ends @ 719842
Atom dinf @ 717063 of size: 36, ends @ 717099
Atom dref @ 717071 of size: 28, ends @ 717099
Atom stbl @ 717099 of size: 2727, ends @ 719826
Atom stts @ 717107 of size: 24, ends @ 717131
Atom stsz @ 717131 of size: 1268, ends @ 718399
Atom stsc @ 718399 of size: 40, ends @ 718439
Atom stco @ 718439 of size: 32, ends @ 718471
Atom stss @ 718471 of size: 1264, ends @ 719735
Atom stsd @ 719735 of size: 91, ends @ 719826
Atom mp4a @ 719751 of size: 75, ends @ 719826
Atom esds @ 719787 of size: 39, ends @ 719826
Atom smhd @ 719826 of size: 16, ends @ 719842
Run Code Online (Sandbox Code Playgroud)
带有mp3音频流的mp4容器
Atom trak @ 1663835 of size: 4844, ends @ 1668679
Atom tkhd @ 1663843 of size: 92, ends @ 1663935
Atom mdia @ 1663935 of size: 4744, ends @ 1668679
Atom mdhd @ 1663943 of size: 32, ends @ 1663975
Atom hdlr @ 1663975 of size: 45, ends @ 1664020
Atom minf @ 1664020 of size: 4659, ends @ 1668679
Atom smhd @ 1664028 of size: 16, ends @ 1664044
Atom dinf @ 1664044 of size: 36, ends @ 1664080
Atom dref @ 1664052 of size: 28, ends @ 1664080
Atom stbl @ 1664080 of size: 4599, ends @ 1668679
Atom stsd @ 1664088 of size: 87, ends @ 1664175
Atom mp4a @ 1664104 of size: 71, ends @ 1664175
Atom esds @ 1664140 of size: 35, ends @ 1664175
Atom stts @ 1664175 of size: 24, ends @ 1664199
Atom stsc @ 1664199 of size: 28, ends @ 1664227
Atom stsz @ 1664227 of size: 2228, ends @ 1666455
Atom stco @ 1666455 of size: 2224, ends @ 1668679
Run Code Online (Sandbox Code Playgroud)
谢谢FE
更新:
我找到了解决问题的方法:通过观察AtomicParsley的代码,我看到有可能获得关于流原子(mp4a)的编解码器信息,将第11个字节读入esds(基本流描述)原子.
现在我正在以这种方式工作:
如果第11个字节的值是0x40我假设流是AAC,否则如果我读取0x69我假设流是MP3.
我不喜欢这些"经验"解决方案,所以我正在寻找更正确的方法,但我发现只有不完整的Understanding_AAC.
有谁知道我可以在哪里获得更详细的MP4容器规格?
小智 29
在'esds'原子中有一些与确定编解码器相关的字段.esds原子内容的第一个字节是objectTypeIndication(这是你解决方案中的第11个字节).该字段应该表示使用的编解码器,但是有多个条目由多个编解码器使用.MP4RA具有完整的编解码器值列表.以下是与此案例相关的一些内容:
0x6B和0x69表示MPEG-1和2分别层1,2和3 0x67表示MPEG-2 AAC LC,但通常是有利于的未使用的0x040(0x66和0x68也MPEG-2 AAC简档甚至更少看出频繁).0x40表示MPEG-4音频.MPEG-4音频通常被认为是AAC但音频编解码器,可以在MPEG-4音频,包括AAC,BSAC,ALS,CELP,以及一些所谓MP3On4去的整体框架.MP3On4是一种MP3变体,带有一些用于多声道的新标题信息.
通过查看,我们可以找出MPEG-4音频中实际的音频格式AudioSpecificConfig.这是解码器的全局头,它存在于'esds'原子内容的第13位.在开头AudioSpecificConfig有一个5位AudioObjectType.一个完整的列表可以在多媒体wiki上找到(即在根据"MPEG-4音频"的文章您的文章被挂:http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio但这里有有用的价值:
如果你不担心'MP3On4'mp3变种,也不用担心其他奇怪的MPEG-4音频编解码器objectTypeIndication.
在MPEG规范中,这些细节分布在14496-1,-12,-14和-3之间.其中只有14496-12可免费获得:http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html
esds atom[1]的格式定义为:
Size 32-bit
Type 32-bit 'esds'
Version: 8-bit, zero.
Flags: 24-bit field, zero.
Elementary Stream Descriptor
Run Code Online (Sandbox Code Playgroud)
基本流描述符在相关的 MPEG4 文档 [2] 中定义。
从 MP4A 文件中查看典型的 ESDS:
00000033 65736473 00000000 03808080
22000100 04808080 14401500 00000001
FC170001 FC170580 80800212 08068080
800102
Run Code Online (Sandbox Code Playgroud)
解释为
00000033 65736473 = ISO Atom "esds" of length 0x33
00000000 = Version/Flags field (0), meaning tagged Elementary Stream Descriptor follows
03808080 = TAG(3) = Object Descriptor ([2])
22 = length of this OD (which includes the next 2 tags)
0001 = ES_ID = 1
00 = flags etc = 0
04808080 = TAG(4) = ES Descriptor ([2]) embedded in above OD
14 = length of this ESD
40 = MPEG4 Audio (see table for valid types here)
15 = stream type(6bits)=5 audio, flags(2bits)=1
000000 = 24bit buffer size
0001FC17 = max bitrate (130,071 bps)
0001FC17 = avg bitrate
05808080 = TAG(5) = ASC ([2],[3]) embedded in above OD
02 = length
1208 = ASC (AOT=2 AAC-LC, freq=4 => 44100 Hz, chan=1 => single channel, flen0 => 1024 samples)
06808080 = TAG(6)
01 = length
02 = data
Run Code Online (Sandbox Code Playgroud)
参考: