根据时间在音频文件中查找
根据数据包级别查找音频文件很简单。在填充下一个缓冲区时,只需更改 currentPacket:
AudioFileReadPackets(_audioFile, false, &numBytes, _packetDescs, _currentPacket, &numPackets, buffer->mAudioData);
但是如果您想定位距离文件开头 10 秒的位置怎么办? 对于 CBR 文件,这应该很容易计算 - 但 VBR 文件呢?
Seeking through an audio file based on the packet level is simple. One just has to change currentPacket when filling the next buffer:
AudioFileReadPackets(_audioFile, false, &numBytes, _packetDescs, _currentPacket, &numPackets, buffer->mAudioData);
But what if you want to seek to position 10s from the beginning of the file?
For the CBR files this should be simple to calculate - but what about VBR files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是使用 ExtAudio* API。人们可以即时将输入文件转换为 LPCM,然后查找就变得微不足道了。
The solution is to use the ExtAudio* API. One can convert the input files to LPCM on the fly and then seeking becomes trivial.