Created
February 20, 2014 18:41
-
-
Save jdelStrother/9120406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSArray* inputURLs = @[[NSURL fileURLWithPath:@"/Users/jon/Desktop/welcome.caf"], [NSURL fileURLWithPath:@"/Users/jon/Desktop/welcome.caf"]]; | |
NSError* error=nil; | |
AVMutableComposition* composition = [AVMutableComposition composition]; | |
for(NSURL* url in inputURLs) { | |
AVMutableCompositionTrack* track = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; | |
AVURLAsset* asset = [AVURLAsset assetWithURL:url]; | |
NSArray* assetTracks = [asset tracksWithMediaType:AVMediaTypeAudio]; | |
AVAssetTrack* assetTrack = assetTracks[0]; | |
[track insertTimeRange:assetTrack.timeRange ofTrack:assetTrack atTime:composition.duration error:&error]; | |
} | |
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:composition presetName:AVAssetExportPresetPassthrough]; | |
exporter.outputURL = [NSURL fileURLWithPath:@"/Users/jon/Desktop/output.caf"]; | |
exporter.outputFileType = AVFileTypeCoreAudioFormat; | |
[exporter exportAsynchronouslyWithCompletionHandler:^{ | |
NSLog(@"Finished! %@ %@", exporter, exporter.error); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment