Я пытаюсь обрезать видео, используя следующий код:
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 я не получаю никаких сведений об ошибке. Кто-нибудь может объяснить, что здесь происходит? Входной видеофайл существует, а выходной видеофайл не существует до того, как я попытаюсь записать в него.
Спасибо,
Джеймс