MPMoviePlayerControllerまたはAVAssetImageGeneratorに、指定した時間にサムネイルを生成するように依頼できます。
iPhone AVFoundationを使用してビデオからUIimage(フレーム)を読み取る
AVAssetImageGeneratorは、回転した画像を提供します
フレームだけでなくビデオが必要な場合は、ビデオからセクションを切り取って、それにエフェクトを適用することができます。これにより、ビデオのURLが取得され、指定された時間にトリミングされます。
AVURLAsset *videoAsset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:videoAsset presetName:AVAssetExportPresetHighestQuality];
exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTimeRange timeRange = CMTimeRangeMake(CMTimeMake(startMilliseconds, 1000), CMTimeMake(endMilliseconds - startMilliseconds, 1000));
exportSession.timeRange = timeRange;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch (exportSession.status) {
case AVAssetExportSessionStatusCompleted:
///
// Call something to apply the effect
///
break;
case AVAssetExportSessionStatusFailed:
NSLog(@"Failed:%@", exportSession.error);
break;
case AVAssetExportSessionStatusCancelled:
NSLog(@"Canceled:%@", exportSession.error);
break;
default:
break;
}
}];
完了したら、エフェクトを適用し、ビデオクリップルートを使用した場合は、それらを組み合わせてエンコードします。
AVFoundationを使用して異なる方向のビデオクリップを組み合わせる方法