NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:self.asset];
? ? if ([compatiblePresets containsObject:AVAssetExportPresetMediumQuality]) {
? ? ? ? self.exportSession = [[AVAssetExportSession alloc] initWithAsset:self.asset presetName:AVAssetExportPresetPassthrough];
? ? ? ? NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
? ? ? ? formatter.dateFormat = @"yyyyMMddHHmmss";
? ? ? ? NSString *str = [formatter stringFromDate:[NSDate date]];
? ? ? ? NSString *videoPath =? [NSTemporaryDirectory() stringByAppendingFormat:@"%@.mp4",str];
?? ? ? ?NSURL *furl = [NSURL fileURLWithPath:videoPath];
? ? ? ? self.exportSession.outputURL = furl;
? ? ? ? self.exportSession.outputFileType = AVFileTypeQuickTimeMovie;
? ? ? ? CMTime start = CMTimeMakeWithSeconds(self.startTime, self.asset.duration.timescale);
? ? ? ? CMTime duration = CMTimeMakeWithSeconds(self.stopTime - self.startTime, self.asset.duration.timescale);
? ? ? ? CMTimeRange range = CMTimeRangeMake(start, duration);
? ? ? ? self.exportSession.timeRange = range;
?? ? ? ?[self.exportSession exportAsynchronouslyWithCompletionHandler:^{
? ? ? ? ? ? switch ([self.exportSession status]) {
?? ? ? ? ? ? ? ?case AVAssetExportSessionStatusFailed:
? ? ? ? ? ? ? ? ? ? NSLog(@"Export failed: %@", [[self.exportSession error] localizedDescription]);
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case AVAssetExportSessionStatusCancelled:
? ? ? ? ? ? ? ? ? ? NSLog(@"Export canceled");
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? NSLog(@"NONE");
? ? ? ? ? ? ? ? ? ? dispatch_async(dispatch_get_main_queue(), ^{
? ? ? ? ? ? ? ? ? ? ? ? ?NSLog(@"剪輯成功");
? ? ? ? ? ? ? ? ? ? });
?? ? ? ? ? ? ? ? ? ?break;
? ? ? ? ? ? }
? ? ? ? }];
? ? }