将两个CAF文件连接在一起 [英] Joining two CAF files together

查看:156
本文介绍了将两个CAF文件连接在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这里有一个简单的问题。我有两个CAF文件。我想要做的就是将它们加入一个长音频文件。

I have the simple problem here. I have two CAF files. All I want to do is to join them to be one long audio file.

我试过:


  • 使用NSData类并将两个文件的音频数据合并为一个。没工作。我假设某些文件属性未正确设置。生成的文件只播放第一个文件的长度。

  • Use the NSData class and append the audio data of both files into one. Hasn't worked. I assume some file property is not being set properly. The resulting file only plays the length of the first file.

尝试在我的加入过程中设置生成的文件的kAudioFilePropertyAudioDataByteCount属性。没有结果。

Tried to set the kAudioFilePropertyAudioDataByteCount property of the resulting file in my joining process. No result.

有人能指出我正确的方向/帮我一些示例代码吗?我见过其他人提出类似的问题并且没有得到答复。希望有人会选择这个。

Could anyone point me in the right direction / help me with some sample code? I have seen other people asking similar questions and going unanswered. Hoping someone would pick this up.

非常感谢您的帮助。谢谢。

Your help is greatly appreciated. Thanks.

推荐答案

如果有人热衷于知道答案,有办法解决。您必须使用AudioFiles API调用。基本上,你需要:

If anyone is keen to know the answer, there is a way to do it. You have to use the AudioFiles API calls. Basically, you'd:


  • 使用带有正确参数的AudioFileCreate创建一个新的音频文件(比特率等)。

  • 打开你的第一个文件,读取数据包并将它们写入新创建的文件。

  • 打开你的第二个文件并执行相同操作。写完第一个文件后,确保你的计数器没有被清零。

  • AudioFileClose - 你已经完成了!

  • create a new audio file using AudioFileCreate with the correct parameters (bitrate etc).
  • open your first file, read the packets and write them to the newly created file.
  • open your second file and do the same. make sure your counters are not zero-ed out after writing the first file.
  • AudioFileClose -- and you're done!

需要注意的事项:
本地文件,你必须运行一个方法来逃避空间

Things to note: for local files, you have to run a method to escape spaces

这就是它!

这篇关于将两个CAF文件连接在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆