Iphone exportAsynchronouslyWithCompletionHandler调用上AVAssetExportSession的访问错误
我正在尝试使用以下代码修剪视频:Iphone exportAsynchronouslyWithCompletionHandler调用上AVAssetExportSession的访问错误,iphone,avfoundation,avassetexportsession,Iphone,Avfoundation,Avassetexportsession,我正在尝试使用以下代码修剪视频: AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@.mp4",documentsDirectory,name]] options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession all
AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@.mp4",documentsDirectory,name]] options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:videoAsset presetName:AVAssetExportPresetHighestQuality];
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"%@/finalOutput.mp4",documentsDirectory]];
exportSession.outputURL = url;
NSLog(@"outputting to: %@", [NSString stringWithFormat:@"%@/finalOutput.mp4",documentsDirectory,name]);
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTimeRange timeRange = CMTimeRangeMake(flashbackStart, CMTimeSubtract(flashbackEnd, flashbackStart));
exportSession.timeRange = timeRange;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch (exportSession.status) {
case AVAssetExportSessionStatusCompleted:
// Custom method to import the Exported Video
//[self loadAssetFromFile:exportSession.outputURL];
NSLog(@"completed!!!");
break;
case AVAssetExportSessionStatusFailed:
//
NSLog(@"Failed:%@",exportSession.error);
break;
case AVAssetExportSessionStatusCancelled:
//
NSLog(@"Canceled:%@",exportSession.error);
break;
default:
break;
}
}];
但是,我得到了一个错误的访问这一行:
[exportSession exportAsynchronouslyWithCompletionHandler:^{
即使启用了NSZombie,我也无法获得有关错误的任何详细信息。有人能解释一下这是怎么回事吗?在我尝试写入之前,输入视频文件确实存在,而输出视频文件不存在
谢谢,
James您可能遇到存储类型问题。尝试将_块添加到exportSession
__block AVAssetExportSession *exportSession...
您可以在此处阅读更多内容:
原来问题出在我使用的
NSURL
s上。我所要做的就是使用initFileURLWithPath
,问题就解决了 谢谢你的回答,但这并没有什么区别。你是在问题中的代码之后发布exportSession的吗?