我正在实施 AVAssetExportSession 来在线修剪视频,但总是返回失败。
这是我的实现:
NSString *url = @"http://www.ebookfrenzy.com/ios_book/movie/movie.mov";
NSURL *fileURL = [NSURL URLWithString:url];
AVAsset *asset = [AVAsset assetWithURL:fileURL];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
NSURL *exportUrl = [NSURL fileURLWithPath:[documentsDirectory stringByAppendingPathComponent:@"export.m4a"]];
exportSession.outputURL = exportUrl;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime time = CMTimeMake(1, 10);
exportSession.timeRange = CMTimeRangeMake(kCMTimeZero, time);
[exportSession exportAsynchronouslyWithCompletionHandler:^(void) {
switch (exportSession.status)
{
case AVAssetExportSessionStatusCompleted:
/*expor is completed*/
NSLog(@"Completed!!");
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"failed!!");
/*failed*/
break;
default:
break;
}
}];
你们中的任何人都知道为什么会发生这种情况或我做错了什么?