获取 AVAssetReader 的示例数据
我正在尝试从 MP3 获取 PCM 数据。我正在使用 AVAssetReaderOutput
,它似乎可以很好地读取数据。
while(true)
{
nextBuffer = [assetReaderOutput copyNextSampleBuffer];
if(nextBuffer)
{
countsample = CMSampleBufferGetNumSamples(nextBuffer);
NSLog(@"%i", countsample);
}
}
我注意到,如果我将 countsample
加起来,它就等于歌曲中的秒数(假设采样率为 44100hz)。因此,我确信阅读处理得非常完美。然而,我想做的是对这些数据执行各种 DSP 过滤器,但我需要对样本信息本身执行此操作。我如何访问示例数据?另外,我注意到 CMSampleBufferGetNumSamples
总是返回 8192
,除了歌曲结尾处。有没有办法提高/降低这个读取率? 谢谢
I'm trying to get the PCM data from an MP3. I'm using AVAssetReaderOutput
and it seems to reading the data fine.
while(true)
{
nextBuffer = [assetReaderOutput copyNextSampleBuffer];
if(nextBuffer)
{
countsample = CMSampleBufferGetNumSamples(nextBuffer);
NSLog(@"%i", countsample);
}
}
I noticed that if I add up countsample
, it equates to the number of seconds in the song (assuming 44100hz sample rate). For this reason, I'm sure the reading is being handled perfectly. What I'd like to do, however, is perform various DSP filters on this data but I need to do it on the sample information itself. How can I access the sample data? Also, I noticed that the CMSampleBufferGetNumSamples
always returned 8192
except at the end of the song. Is there a way to increase/decrease this read rate?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将数据附加到
NSMutableData
对象。假定
countsample
和nextBuffer
已存在于您的代码中。Append the data to a
NSMutableData
object.countsample
andnextBuffer
are assumed to already exist in your code.