Join multiple audio files into one

前端 未结 1 1563
Happy的楠姐
Happy的楠姐 2021-01-15 03:14

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 f

1条回答
  •  天涯浪人
    2021-01-15 03:41

    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.

    0 讨论(0)
提交回复
热议问题