我想使用AVFoundation中的类获取视频的第一帧。但它似乎没有得到一个图像。使用AVFoundation的视频的第一帧
我的代码目前看起来像这样
AVURLAsset* asset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:videoPath] options:nil];
AVAssetImageGenerator* imageGenerator = [AVAssetImageGenerator assetImageGeneratorWithAsset:asset];
UIImage* image = [UIImage imageWithCGImage:[imageGenerator copyCGImageAtTime:CMTimeMake(0, 1) actualTime:nil error:nil]];
[videoFrame setImage:image];
视频路径的值是/var/mobile/Applications/02F42CBF-D8BD-4155-85F2-8CF1E55B5023/Documents/videos/1334300431637030.mp4
这绝对是一个视频,因为我可以MPMoviePlayerViewController
播放。我不确定我做错了什么,但任何建议都会有所帮助。
谢谢。