我有用MPEG-2 AAC编码的单独音频帧。每帧由1024个16位PCM样本组成。
我注意到每个AAC框架的大小不同。我认为这是MPEG-2 AAC压缩算法的结果,非常正常。
我需要一种方法来解码单个帧并获取原始的1024个PCM样本(有损压缩的错误,这很好)。
我无法在线找到有关MPEG-2 AAC算法 ANYWHERE 的信息。这有点疯狂。
我一直在努力使用名为pydub
的库,其中包含一些使用FFMPEG的AAC解码器的方法。尝试使用AAC编码将音频帧加载为AudioSegment:
audioData = BytesIO(frame)
sound = AudioSegment.from_file(audioData, format="aac")
给出以下错误:
[aac @ 000002d444c1aa00] Estimating duration from bitrate, this may be inaccurate\r\n
Input #0, aac, from 'C:\\Users\\jmk_m\\AppData\\Local\\Temp\\tmpjl3x0xao':\r\n
Duration: 00:00:00.19, bitrate: 23 kb/s\r\n
Stream #0:0: Audio: aac (LC), 22050 Hz, mono, fltp, 23 kb/s\r\nStream mapping:\r\n
Stream #0:0 -> #0:0 (aac (native) -> pcm_s16le (native))\r\n
Press [q] to stop, [?] for help\r\n
Output #0, wav, to 'C:\\Users\\jmk_m\\AppData\\Local\\Temp\\tmpxmp942e4':\r\n
Metadata:\r\n
ISFT : Lavf58.10.100\r\n
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 22050 Hz, mono, s16, 352 kb/s\r\n
Metadata:\r\n encoder : Lavc58.13.100 pcm_s16le\r\n
[aac @ 000002d444cc7480] Reserved bit set.\r\n
[aac @ 000002d444cc7480] Prediction is not allowed in AAC-LC.\r\n
Error while decoding stream #0:0: Invalid data found when processing input\r\n
[aac @ 000002d444cc7480] Reserved bit set.\r\n
[aac @ 000002d444cc7480] Prediction is not allowed in AAC-LC.\r\n
Error while decoding stream #0:0: Invalid data found when processing input\r\n
[aac @ 000002d444cc7480] Prediction is not allowed in AAC-LC.\r\n
Error while decoding stream #0:0: Invalid data found when processing input\r\n
size= 2kB time=00:00:00.04 bitrate= 366.2kbits/s speed=5.45x \r\n
video:0kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 3.808594%\r\n
Conversion failed!\r\n"
如果有人对可能导致错误的原因或任何其他方法有任何见解,那将不胜感激!