mp4 atom-如何区分音频编解码器?是AAC还是MP3?

问题描述 投票:12回答:3

我正在研究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

带有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

谢谢FE

UPDATE:

我找到了解决问题的方法:通过查看AtomicParsley的代码,我看到有可能获得有关流原子(mp4a)的编解码器信息,读取第11个字节进入esds(基本流描述)原子。

现在我正在以这种方式工作:

[如果第11个字节的值是0x40,则假定流是AAC,否则,如果我读取0x69,则假定流是MP3。

我不喜欢这些“经验”解决方案,因此我正在寻找更正确的方法方式,但我发现只有Understanding_AAC不完整。

任何人都知道我可以在哪里获得更详细的MP4容器规范吗?

audio mp4 codec
3个回答
29
投票

在“ esds”原子中,有一些字段与确定编解码器有关。 esds原子的内容的第一个字节是objectTypeIndication(这是您解决方案中的第11个字节)。该字段应该指示使用的编解码器,但是多个编解码器使用了一些条目。 MP4RA有一个full list of codec values。以下是与这种情况相关的一些信息:

  • 0x40-MPEG-4音频
  • 0x6B-MPEG-1音频(MPEG-1层1、2和3)
  • 0x69-MPEG-2向后兼容音频(MPEG-2层1、2和3)
  • 0x67-MPEG-2 AAC LC

[0x6B0x69分别表示MPEG-1和2的第1、2和3层。0x67表示MPEG-2 AAC LC,但通常不使用,而倾向于0x0400x66和[C0 ]也是MPEG-2 AAC配置文件出现的频率更低。 0x68表示MPEG-4音频。 MPEG-4音频通常被认为是AAC,但是在MPEG-4音频中可以使用一个完整的音频编解码器框架,包括AAC,BSAC,ALS,CELP和称为MP3On4的东西。 MP3On4是MP3变体,具有一些用于多通道的新标题信息。

通过查看0x40,我们可以找出MPEG-4音频中实际上是哪种音频格式。这是存在于“ esds”原子内容的字节13中的解码器的全局头。在AudioSpecificConfig的开头有一个5位的AudioSpecificConfig。可以在多媒体Wiki上找到完整列表(该链接在您的帖子的“ MPEG-4 Audio”文章下链接:AudioObjectType,但这是有用的值:

  • 00-空
  • 01-AAC Main(MPEG-2中已弃用的AAC配置文件)
  • 02-AAC LC或向后兼容的HE-AAC(大多数现实世界中的AAC属于这些情况之一)
  • 03-AAC可缩放采样率(很少使用)
  • 03-AAC LTP(AAC Main的替代品,很少使用)
  • 05-HE-AAC明确发出信号(不向后兼容)
  • 22-ER BSAC(韩国广播编解码器)
  • 23-低延迟AAC
  • 29-HE-AACv2明确发出信号(在一份草案中,这是MP3On4)
  • 31-ESCAPE(再读6位,加32)
  • 32-MP3on4第1层
  • 33-MP3on4第2层
  • 34-MP3on4第3层

[如果您不担心'MP3On4'mp3变体或其他怪异的MPEG-4音频编解码器,则只需使用http://wiki.multimedia.cx/index.php?title=MPEG-4_Audio

在MPEG规范中,这些详细信息遍布14496-1,-12,-14和-3。其中只有14496-12是免费提供的:objectTypeIndication


5
投票

esds原子[1]的格式定义为:

http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html

[基本流描述符在相关的MPEG4文档[2]中定义。

从MP4A文件中查看典型的ESDS:

Size 32-bit
Type 32-bit 'esds'
Version: 8-bit, zero.
Flags: 24-bit field, zero.
Elementary Stream Descriptor

解释为

00000033 65736473 00000000 03808080  
22000100 04808080 14401500 00000001
FC170001 FC170580 80800212 08068080
800102

参考:

  • [1] 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
  • [3] ASC是AudioSpecificConfig,请参见https://wikileaks.org/sony/docs/05/docs/Apple/qtff.pdf

0
投票
从Andy Henson的答案中拆分出来的字段是错误的,'0x80'字节不是标签的一部分,而是长度的一部分,并形成Varint32长度。

https://wiki.multimedia.cx/index.php/MPEG-4_Audio

在MPEG-4系统(ISO 14496-1),附件E.1中记录了长度编码
© www.soinside.com 2019 - 2024. All rights reserved.