/**
* 合成 ???
* 不会 覆盖 原文件 (存在原文件导致失败)
*/
+ (BOOL)SyntheticFileWith:(AVMutableComposition *)composition AndFilePath:(NSString *)mainFilePathString AndFinishBlock:(void(^)(BOOL success))block{
// create the export session
// no need for a retain here, the session will be retained by the
// completion handler since it is referenced there
AVAssetExportSession *exportSession = [AVAssetExportSession
exportSessionWithAsset:composition
presetName:AVAssetExportPresetAppleM4A];
if (nil == exportSession) return NO;
//NSLog(@"Output file path - %@",soundOneNew);
// configure export session output with all our parameters
exportSession.outputURL = [NSURL fileURLWithPath:mainFilePathString]; // output path
exportSession.outputFileType = AVFileTypeAppleM4A; // output file type
// perform the export
[exportSession exportAsynchronouslyWithCompletionHandler:^{
if (AVAssetExportSessionStatusCompleted == exportSession.status) {
NSLog(@"AVAssetExportSessionStatusCompleted");
block(YES);
} else if (AVAssetExportSessionStatusFailed == exportSession.status) {
// a failure may happen because of an event out of your control
// for example, an interruption like a phone call comming in
// make sure and handle this case appropriately
NSLog(@"AVAssetExportSessionStatusFailed");
block(NO);
} else {
NSLog(@"Export Session Status: %d", exportSession.status);
block(NO);
}
}];
return YES;
}