简体   繁体   中英

How to mix two mp3 files in and generate one in iPhone app

I have two mp3 files, a.mp3 of 5 seconds and b.mp3 of 7 seconds and I want to mix them in order to generate c.mp3 of duration 7 secs. I have tried the following code Example 4 of the following link http://www.modejong.com/iOS/#ex4

but it mixes only caf files and I need to mix the MP3 files of different sizes.

Thanks-

You need to use AVMutableCompositionTrack and AVAssetExportSession Class to do it.

Here is a sample code on developer.Apple.com .

This is a nice tutorial which merge two video files and one music file into a single file. This same code can be reused to merge two audio files.

Here for your requirement you can use this bellow demo code with convert two .mp3 or caf file to one file , see the tutorial and get some idea and also use these Demos ..

Please see this bellow links with sample codes and tutorials..

  1. AudioConverterFileConvert

  2. iPhoneExtAudioFileConvertTest

i hope this help you...

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