Hi folks,
I'm struggling with an issue with using AVAssetExportSession.
I wish to have greater control over my exported video file by using
AVAssetExportSession instead of just accepting the video as provided by the
UIImagePicker following capturing the image, and then saving it to the media
library. I then wish to use an export session in order to copy/transcode the
asset to a temporary file.
I am saving the file successfully to the media library, and then wish to
initiate an export session based on the URL handed back to me from saving the
file to the library. However, the export session is failing with the error:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be
completed" UserInfo=0x6bcf710 {NSLocalizedFailureReason=An unknown error
occurred (-12780), NSUnderlyingError=0x6bcd4f0 "The operation couldn’t be
completed. (OSStatus error -12780.)", NSLocalizedDescription=The operation
could not be completed}
I am attempting to write the file into my application documents directory, and
can successfully write to the same path using other methods. No file exists at
the target location when I attempt to run this method.
Any advice or insight would be greatly appreciated.
My code is as follows:
- (void)copyTempVideoToMediaLibrary {
dispatch_queue_t mainQueue =
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(mainQueue, ^{
ALAssetsLibrary *library = [[[ALAssetsLibrary alloc] init] autorelease];
ALAssetsLibraryWriteVideoCompletionBlock completionBlock = ^(NSURL
*assetURL, NSError *error) {
NSLog(@"Saved URL: %@", assetURL);
NSLog(@"Error: %@", error);
if (assetURL != nil) {
AVURLAsset *theAsset = [AVURLAsset URLAssetWithURL:assetURL
options:nil];
NSArray *compatiblePresets = [AVAssetExportSession
exportPresetsCompatibleWithAsset:theAsset];
AVAssetExportSession *exportSession = [[AVAssetExportSession
alloc] initWithAsset:theAsset presetName:AVAssetExportPresetHighestQuality];
[exportSession setOutputURL:[NSURL URLWithString:[self
mediaTempUrl]]];
[exportSession setOutputFileType:AVFileTypeQuickTimeMovie];
[exportSession exportAsynchronouslyWithCompletionHandler:^ {
switch ([exportSession status]) {
case AVAssetExportSessionStatusFailed:
NSLog(@"Export session faied with error: %@",
[exportSession error]);
break;
default:
[self mediaIsReady];
break;
}
}];
}
};
[library writeVideoAtPathToSavedPhotosAlbum:[NSURL URLWithString:[self
objectUrl]] completionBlock:completionBlock];
});
}
Many thanks,
Josh
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]