0

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.

4

1 回答 1

0

在此处阅读有关文件类型的更多信息:

https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVFoundation_Constants/Reference/reference.html#//apple_ref/doc/uid/TP40009539

NSString *const AVFileTypeAIFC;
NSString *const AVFileTypeAIFF;
NSString *const AVFileTypeAMR;
NSString *const AVFileTypeCoreAudioFormat;
NSString *const AVFileTypeAppleM4V;
NSString *const AVFileTypeMPEG4;
NSString *const AVFileTypeAppleM4A;
NSString *const AVFileTypeQuickTimeMovie;
NSString *const AVFileTypeWAVE

AIFC 可能对您来说很有趣,因为它是压缩的。

您还必须将 presetName:AVAssetExportPresetAppleM4A 更新为 presetName:AVAssetExportPresetPassthrough

于 2013-09-12T13:34:13.447 回答