blog

ウェブ最初のスカウトをカバー画像として取得する

最初に2つのフレームを追加...

Feb 29, 2020 · 1 min. read
シェア

まず、2つのフレームを追加します。

#import <AVFoundation/AVFoundation.h>
#import <CoreMedia/CoreMedia.h>
+ (UIImage *)ym_firstFrameWithVideoURL:(NSURL *)url imageSize:(CGSize)size{
 // 最初のフレームを取得する
 NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
 AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:opts];
 AVAssetImageGenerator *generator = [AVAssetImageGenerator assetImageGeneratorWithAsset:urlAsset];
 generator.appliesPreferredTrackTransform = YES;
 generator.maximumSize = CGSizeMake(size.width, size.height);
 NSError *error = nil;
 CGImageRef img = [generator copyCGImageAtTime:CMTimeMake(0, 10) actualTime:NULL error:&error];
 { 
 return [UIImage imageWithCGImage:img];
 } 
 return nil;
}
Read next

影響力のある原子力エネルギーの秘密

今朝、おそらく影響力の核心に迫る本『影響力の核心』を初見したので、影響力に関する記事を簡単に書いてシェアします。 この本は、「影響力の核心」(Nuclear Power of Influence)という本です。

Feb 29, 2020 · 4 min read