简体   繁体   中英

Join multiple audio files into one

I'm trying to allow selection of words (mp3 audio samples) and add to a sentence which upon pressing play plays them all in sequence and optionally save that one combined file.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM