指定した時点でサムネイルを生成するようにMPMoviePlayerControllerまたはAVAssetImageGeneratorに問い合わせることができます。
iPhone Read UIimage (frames) from video with AVFoundation
AVAssetImageGenerator provides images rotated
あなたがビデオを好きなだけではなくフレームたい場合は、ビデオのうちの部分をトリミングし、それにエフェクトを適用することができます。これは、あなたのビデオの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;
}
}];
完了したら、エフェクトを適用し、ビデオクリップのルートに参加していれば、それらを結合してエンコードします。
How to combine video clips with different orientation using AVFoundation
ブランドン、代替ソリューションをありがとう。つまり、5秒から10秒の間にビデオにエフェクトを適用する場合、この5秒間のビデオをエクスポートしてから、GPUImageを使用してエフェクトを適用して元のビデオに挿入する必要がありますか? – iMOBDEV
はい、それは私が見つけることができる最高の解決策のようです。私は確かにこれで専門家ではないので、他の誰かがより良い答えを持っているかもしれません。 –
あなたのソリューションをありがとう、私はすでにこれを考えていましたが、私はこれに対してより良い解決策が必要です。異なる時間枠に複数の効果を適用すると時間がかかるかもしれないからです。 – iMOBDEV