人力検索はてな
モバイル版を表示しています。PC版はこちら
i-mobile

(iOS,iPhone,Objective-C)動画からサムネイル高速生成
動画からサムネイルを生成する際に以下のようにAVAssetImageGenerator:copyCGImageAtTimeを使用しているのですが、1枚の画像を切り出すのに0.2秒ほどかかってしまいます。これを高速化する方法はないでしょうか?iMovieなどは一瞬でサムネイルが表示されのですが、これと同等のことがしたいです。

他にはAVAssetReaderのcopyNextSampleBufferでバッファの読み出しからUIImageに変換する処理も試してみましたが、こちらはcopyNextSampleBufferのバッファ読み出しに時間がかかってしまう状況でした。


AVAssetImageGenerator *imageGen = [[AVAssetImageGenerator alloc] initWithAsset:_mutablComposition];
imageGen.maximumSize = CGSizeMake(210, 210);

NSError* error = nil;
CMTime actualTime;
CMTime midpoint;
Float64 step = 0;
midpoint = kCMTimeZero;

for(UIImageView *imageView in _scrollView.subviews ){

if( imageView.tag ){

midpoint = CMTimeMake(step, 600);

CGImageRef halfWayImageRef = [imageGen copyCGImageAtTime:midpoint actualTime:&actualTime error:&error];
if ( halfWayImageRef != nil ){
}
step += 1200;
CGImageRelease(halfWayImageRef);
}
}

●質問者: ankomoti3260
●カテゴリ:コンピュータ
○ 状態 :終了
└ 回答数 : 1/1件

▽最新の回答へ

1 ● dilutionist
●500ポイント ベストアンサー

generateCGImagesAsynchronouslyForTimes:completionHandler: はどうでしょうか。

avfoundation - AV Foundationを使った動画編集(動画ファイルのサムネイルの取得) - Qiita

Creating video thumbnails using the iOS SDK


ankomoti3260さんのコメント
有り難うございます。 generateCGImagesAsynchronouslyForTimesを試したところ、サムネイル生成の高速化が出来るようになりました。
関連質問

●質問をもっと探す●



0.人力検索はてなトップ
8.このページを友達に紹介
9.このページの先頭へ
対応機種一覧
お問い合わせ
ヘルプ/お知らせ
ログイン
無料ユーザー登録
はてなトップ