2
AVAsset에로드 할 수있는 비디오 파일이 있습니다. 이 비디오의 속도를 변경하고 비디오가 재생되는 속도를 두 배로 늘리므로 비디오 길이가 10 초인 경우 5 초 안에 완료됩니다.AVAssetExportSession을 사용하여 비디오를 저장할 때 비디오 속도를 높이는 방법
내가 시도한 코드는 다음과 같습니다. 누군가 내가 잘못 가고 있다고 말할 수 있습니까?
프레임 기간은 내 목표를 달성하는 데 필요한 속성입니다.
AVAsset *anAsset = self.moviePlayer.currentItem.asset;
NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:anAsset];
if ([compatiblePresets containsObject:AVAssetExportPreset640x480]) {
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:anAsset presetName:AVAssetExportPreset640x480];
// Implementation continues.
NSString *tmpStr = [[aclip selectedTakeUrl] stringByReplacingOccurrencesOfString:@".m4v" withString:@""];
NSString *filePath = [NSString stringWithFormat:@"%@_applied.m4v", tmpStr];
exportSession.outputURL = [NSURL fileURLWithPath:filePath];
AVMutableVideoComposition *vidcomp = [AVMutableVideoComposition videoCompositionWithPropertiesOfAsset:anAsset];
vidcomp.frameDuration = CMTimeMake(1, 24);
//self.moviePlayer.currentItem.videoComposition = vidcomp;
exportSession.videoComposition = vidcomp;
//exportSession.videoComposition.frameDuration = CMTimeMake(1, 50);
// what is the song URL before loading startRecordingViewController?
NSLog(@"From Save settgins Choose Song -Song URL : %@", exportSession.outputURL);
// NSLog(@"start time%f, end time %f", CMTimeGetSeconds(self.startTime),CMTimeGetSeconds(self.endTime));
exportSession.outputFileType = AVFileTypeMPEG4;
//CMTimeRange range = CMTimeRangeMake(CMTimeMake(0.0, 1), CMTimeMake(diffTime/currentround,1));
// startTime and endTime is the duration that we need to save.
//exportSession.timeRange = range;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch ([exportSession status]) {
case AVAssetExportSessionStatusCompleted:
NSLog(@"Export Completed");
break;
case AVAssetExportSessionStatusWaiting:
NSLog(@"Export Waiting");
break;
case AVAssetExportSessionStatusExporting:
NSLog(@"Export Exporting");
break;
case AVAssetExportSessionStatusFailed:
{
NSError *error = [exportSession error];
NSLog(@"Export failed: %@", [error localizedDescription]);
break;
}
case AVAssetExportSessionStatusCancelled:
NSLog(@"Export canceled");
break;
default:
break;
}
dispatch_async(dispatch_get_main_queue(), ^{
//[activityIndicator stopAnimating];
//CMTime range = CMTimeSubtract(self.endTime, self.startTime);
//NSUInteger theLength = (int)CMTimeGetSeconds(range);
//[ self.songPickedDelegate songPickerDidMakeSelection:self.songTitle :self.audioPath :theLength];
});
//[exportSession release];
}];
}
이미 완료되었습니다. 감사합니다. – Jatin
@ user3196356 예를 들어 보셨습니까? 이것에 대한 예제가 거의없고 문서를 읽는 것이 도움이되지 않는 것 같습니다. 필요한 경우 알려 주시면 코드를 공유하겠습니다. 아무런 결과가 없습니다. –
@PranoyC는이 코드를 사용하여 https://developer.apple.com/library/content/samplecode/AVSimpleEditoriOS/Introduction을 시작합니다. /Intro.html – thedeveloper3124