1
votes

Is there a way to blur the content being displayed in a AVPlayerLayer?
The content is a streamed asset (m3u8) so no option for AVAssetReader etc.

1

1 Answers

0
votes

Try to use next solution to get image:

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);
}

And then apply blur to it:

CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur" 
                              keysAndValues:@"inputRadius", @9.0,
                                            @"inputImage", snapshotImage, nil];
CIImage *resultImage = [filter outputImage];
UIImage *resultUIImage = [UIImage imageWithCIImage:resultImage];