相关疑难解决方法(0)

从iOS中的视频网址或数据中获取缩略图

我试图从iphone 3GS相机拍摄的视频中获取(第一帧的)缩略图,以便我可以显示它.这该怎么做?

iphone video thumbnails ios

59
推荐指数
7
解决办法
7万
查看次数

iOS - 如何在没有游戏的情况下从视频获取缩略图?

我正在尝试从视频中获取缩略图并在我的tableview中显示它.这是我的代码:

- (UIImage *)imageFromVideoURL:(NSURL *)contentURL {
    AVAsset *asset = [AVAsset assetWithURL:contentURL];

    //  Get thumbnail at the very start of the video
    CMTime thumbnailTime = [asset duration];
    thumbnailTime.value = 25;

    //  Get image from the video at the given time
    AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];

    CGImageRef imageRef = [imageGenerator copyCGImageAtTime:thumbnailTime actualTime:NULL error:NULL];
    UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);

    return thumbnail;
}
Run Code Online (Sandbox Code Playgroud)

但是图像总是回归黑色.怎么了?

image ios video-thumbnails

10
推荐指数
3
解决办法
1万
查看次数

标签 统计

ios ×2

image ×1

iphone ×1

thumbnails ×1

video ×1

video-thumbnails ×1