I use AVAudioRecorder
to record sound, the out put file format is .caf
. And then I add a background sound (which is also in .caf
format) onto the audio that I recorded, with AVMutableComposition
. It works perfectly when I try to play it.
Now I want to export it and save it with the following code. However, the filesize of the exported file increase a lot. (for instance, the audio that I record is 16045byte, the background sound is 50400byte, and the exported file is 246472byte which is larger than the sum of the two file by times.)
AVAssetExportSession *export = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetAppleM4A];
export.audioMix = audioMix;
export.outputFileType = AVFileTypeAppleM4A;
NSString *exportURL = [NSString stringWithFormat:@"%@/export.m4a", DOCUMENTS_FOLDER];
NSURL *outputURL = [NSURL fileURLWithPath:exportURL];
export.outputURL = outputURL;
[export exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = export.status;
switch (exportStatus) {
// check the status and do the handling
}
}];
}
So, can some one teach me to how I can make the output audio file smaller? Thanks.