#import <AVFoundation/AVAsset.h>
#import <AVFoundation/AVAssetImageGenerator.h>
#import <AVFoundation/AVTime.h>
- // 获取视频第一帧
- - (UIImage*) getVideoPreViewImage:(NSURL *)path
- {
- AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:path options:nil];
- AVAssetImageGenerator *assetGen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
-
- assetGen.appliesPreferredTrackTransform = YES;
- CMTime time = CMTimeMakeWithSeconds(0.0, 600);
- NSError *error = nil;
- CMTime actualTime;
- CGImageRef image = [assetGen copyCGImageAtTime:time actualTime:&actualTime error:&error];
- UIImage *videoImage = [[UIImage alloc] initWithCGImage:image];
- CGImageRelease(image);
- return videoImage;
- }
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。