使用AVAssetExportSession修剪视频期间获取AVAssetExportSessionStatusFailed

时间:2016-03-12 04:09:35

标签: ios

我正在处理一个处理视频的应用程序。现在我想使用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;

         }
     }];
}

0 个答案:

没有答案