视频导出问题不到12秒

时间:2015-01-29 12:57:28

标签: ios media avassetexportsession

我将使用此代码

导出不到12秒的视频
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoToTrimURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = [NSURL fileURLWithPath:outputURL]; // output path
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie; // output file type
CMTime start = CMTimeMakeWithSeconds(self.startTime, 600);

if (self.stopTime == 0) {
    NSTimeInterval time = session.duration;
    self.stopTime = time;
}
CMTime duration = CMTimeMakeWithSeconds(self.stopTime, 600);
CMTimeRange range = CMTimeRangeMake(start, duration);
exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
 {
 switch (exportSession.status) {
     case AVAssetExportSessionStatusCompleted:
     {
         NSLog(@"Export Complete %ld %@", (long)exportSession.status, exportSession.error);
     }
         break;
     case AVAssetExportSessionStatusFailed:
         NSLog(@"Failed:%@",exportSession.error);
         break;
     case AVAssetExportSessionStatusCancelled:
         NSLog(@"Canceled:%@",exportSession.error);
         break;
     default:
         break;
 }
 }];

第二种情况是下面提到的错误

AVAssetExportSessionStatusFailed

Failed:Error Domain=AVFoundationErrorDomain Code=-11829 "Cannot Open" UserInfo=0x17d79000 {NSLocalizedFailureReason=This media may be damaged., NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x17d598f0 "The operation couldn’t be completed. (OSStatus error -12848.)", NSURL=file:///private/var/mobile/Applications/0A019551-6DEA-4BE5-B128-2A080EE1800C/tmp/movie2015-01-29%2012:27:44%20+0000.mov}

如果我在录制后导出的视频时间超过12秒,则完全存储到文档目录。

我做了很多研究工作,但无法为此问题找到合适的解决方案。任何帮助都是提前高度赞赏的。

0 个答案:

没有答案