iOS -视频缩略图的制作

复制代码
 1  +(UIImage *)getImage:(NSString *)videoURL
 2 
 3 {
 4 
 5     AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:[NSURL fileURLWithPath:videoURL] options:nil];
 6 
 7     AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
 8 
 9     gen.appliesPreferredTrackTransform = YES;
10 
11     CMTime time = CMTimeMakeWithSeconds(0.0, 600);
12 
13     NSError *error = nil;
14 
15     CMTime actualTime;    
16 
17     CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
18 
19     UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
20 
21     CGImageRelease(image);
22 
23     return thumb;
24 
25  
26 
27 }
复制代码

 

posted @   Qingyun_Qearl  阅读(480)  评论(0编辑  收藏  举报
编辑推荐:
· 自定义通信协议——实现零拷贝文件传输
· Brainfly: 用 C# 类型系统构建 Brainfuck 编译器
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
阅读排行:
· DeepSeek 全面指南,95% 的人都不知道的9个技巧(建议收藏)
· 自定义Ollama安装路径
· 本地部署DeepSeek
· 快速入门 DeepSeek-R1 大模型
· DeepSeekV3+Roo Code,智能编码好助手
点击右上角即可分享
微信分享提示