我正在处理一个处理视频的应用程序。现在我想使用AVAssetsExpertSession
修剪此视频但是在修剪此视频时我得到AVAssetExpertSessionStatusFailed
。请帮助我们。
- (void)trimVideo:(NSString *)outputURL assetObject:(AVAsset *)asset
{
float videoStartTime=2.0f;
float videoEndTime=5.0f;
@try
{
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime startTime = CMTimeMake((int)(floor(videoStartTime * 100)), 100);
CMTime stopTime = CMTimeMake((int)(ceil(videoEndTime * 100)), 100);
CMTimeRange range = CMTimeRangeFromTimeToTime(startTime, startTime);
exportSession.timeRange = range;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[self checkExportSessionStatus:exportSession];
//[exportSession release];
exportSession = nil;
}
@catch (NSException * e)
{
NSLog(@"Exception Name:%@ Reason:%@",[e name],[e reason]);
}
}
- (void)checkExportSessionStatus:(AVAssetExportSession *)exportSession
{
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
switch ([exportSession status])
{
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export Completed");
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Error in exporting");
break;
default:
break;
}
}];
}