将多个音频文件合并为一个 [英] Join multiple audio files into one

查看:101
本文介绍了将多个音频文件合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试允许选择单词(mp3音频样本)并添加到句子中,按一下播放后,它们将按顺序播放所有单词,并可以选择保存该组合文件。

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是一种流格式,这意味着它在文件的开头或结尾没有一堆元数据。尽管这有很多缺点,但缺点之一是您可以将MP3文件连接成一个文件,然后播放。

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.

您可以通过串联到NSMutableData来完成此操作,其缺点是您可能会用完内存。另一个选择是使用NSFileHandle在磁盘上建立文件。

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.

这不适用于大多数文件格式(aac / m4a,aif,caf等)。 。 MP3实际上只是一个流,它被转储到磁盘上,元数据放在帧头中(或者在ID3中,放在帧之间),所以这才起作用。

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.

这篇关于将多个音频文件合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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