有没有办法模糊AVPlayerLayer中显示的内容?
内容是流资产(m3u8),因此AVAssetReader等没有选项。
答案 0 :(得分:0)
尝试使用下一个解决方案来获取图片:
CIImage *snaphotImage = nil;
AVPlayerItem *item = ((AVPlayerLayer*)view.layer).player.currentItem;
if (item.status == AVPlayerItemStatusReadyToPlay)
{
AVURLAsset *asset = (AVURLAsset *)item.asset;
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
CGImageRef thumb = [imageGenerator copyCGImageAtTime:((AVPlayerLayer*)view.layer).player.currentTime
actualTime:NULL
error:NULL];
snapshotImage = [CIImage imageWithCGImage:thumb];
CGImageRelease(thumb);
}
然后对它应用模糊:
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"
keysAndValues:@"inputRadius", @9.0,
@"inputImage", snapshotImage, nil];
CIImage *resultImage = [filter outputImage];
UIImage *resultUIImage = [UIImage imageWithCIImage:resultImage];