I am using below code to get the Audio from library for triming
here my problem is i am able to get the the audio but is is taking long time to get the audio
AAVURLAsset *songAsset = [AVURLAsset URLAssetWithURL:appDelegate.librarySongURL options:nil];
NSLog (@"Core Audio %@ directly open library URL %@",
coreAudioCanOpenURL (appDelegate.librarySongURL) ? @"can" : @"cannot",
appDelegate.librarySongURL);
NSLog (@"compatible presets for songAsset: %@",
[AVAssetExportSession exportPresetsCompatibleWithAsset:songAsset]);
AVAssetExportSession *exporter = [[AVAssetExportSession alloc]
initWithAsset: songAsset
presetName: AVAssetExportPresetAppleM4A];
NSLog (@"created exporter. supportedFileTypes: %@", exporter.supportedFileTypes);
[self handlePlayPauseDefault:0];
exporter.outputFileType = @"com.apple.m4a-audio";
NSString *exportFile = [myDocumentsDirectory() stringByAppendingPathComponent: @"exported.m4a"];
myDeleteFile(exportFile);
appDelegate.libraryUrl = [NSURL fileURLWithPath:exportFile];
exporter.outputURL = appDelegate.libraryUrl;
[exporter exportAsynchronouslyWithCompletionHandler:^{
int exportStatus = exporter.status;
switch (exportStatus) {
case AVAssetExportSessionStatusFailed: {
NSError *exportError = exporter.error;
NSLog (@"AVAssetExportSessionStatusFailed: %@", exportError);
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog (@"AVAssetExportSessionStatusCompleted");
self.navigationController.navigationBar.userInteractionEnabled = YES;
break;
}
case AVAssetExportSessionStatusUnknown: { NSLog (@"AVAssetExportSessionStatusUnknown"); break;}
case AVAssetExportSessionStatusExporting: { NSLog (@"AVAssetExportSessionStatusExporting"); break;}
case AVAssetExportSessionStatusCancelled: { NSLog (@"AVAssetExportSessionStatusCancelled"); break;}
case AVAssetExportSessionStatusWaiting: { NSLog (@"AVAssetExportSessionStatusWaiting"); break;}
default: { NSLog (@"didn't get export status"); break;}
}
}];
can any one help me ?
You’re probably causing some kind of conversion – that will be slow (not that much faster than realtime). Make sure you’re using the passthrough preset, AVAssetExportPresetPassthrough.