gpt4 book ai didi

iphone - 如何使用 iPhone SDK 合并两个音频文件?

转载 作者:行者123 更新时间:2023-11-28 18:40:24 25 4
gpt4 key购买 nike

我想在我的 iPhone 应用程序中合并两个 .caf 音频文件?

你能告诉我怎么做吗?

谢谢!

最佳答案

选项 1:

引用这个链接:

Join multiple audio files into one

该帖子中invalidname 的回答是:

MP3 is a stream format, meaning it doesn't have a bunch of metadata at the front or end of the file. While this has a lot of downsides, one of the upsides is that you can concatenate MP3 files together into a single file and it'll play.

This is pretty much what you're doing by concatenating into an NSMutableData, the downside of which is that you might run out of memory. Another option would be to build up the file on disk with NSFileHandle.

This doesn't work for most file formats (aac/m4a, aif, caf, etc.). MP3 is literally just a stream dumped to disk, with metadata in frame headers (or, in ID3, tucked between frames), so that's why it works.

选项 2:

combine two .caf audio files into a single audio file in iphone

Midhere 在这篇文章中的回答:

You can do it using ExtAudioFileService. In ios developer library they had provided two examples to convert one audio file to another format. In these they are opening one audio file for reading and another file for writing (converted audio). You can change or updated code to read from two files and write them to one out put file in same format(caf) or compressed format. First you have open first audio file and read every packets from it and write it to a new audio file. After finishing first audio file, close the file and open second audio file for reading. Now read every packets from second audio file and write to newly created audio file and close second audio file and new audio file.

Please find the links(1,2) for these sample codes .... Hope this helps you...and good luck. :)

因此尝试将其转换为另一种格式,然后尝试将其组合。

选项 3:

引用:

Joining two CAF files together

dineth 在这篇文章中的回答:

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:

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

That's about it!

选项 4:

略有不同。

我认为您正在用 CAF 录制文件并尝试合并它们。所以在这种情况下,您最终可以尝试以 caf 以外的其他格式录制文件。

试试这个链接:

iOS: Record audio in other format than caf

希望这对您有所帮助。

关于iphone - 如何使用 iPhone SDK 合并两个音频文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11681865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com