Raj Upadhyay Raj Upadhyay - 1 year ago 74
iOS Question

How to capture still image from custom video player screen in iOS?

I just create my own custom video player using

library's AVPlayer* myPlayer. Now I want to capture images for bookmarks of video from running playing video on
. On click
it take snapshot of player screen and store in document directory.
Please suggest me how to do it?
Thank you in advance.

Answer Source
AVAsset *asset = [AVAsset assetWithURL:sourceURL];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
CMTime time = CMTimeMake(1, 1);
CGImageRef imageRef = [imageGenerator copyCGImageAtTime:time actualTime:NULL error:NULL];
UIImage *thumbnail = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);  // CGImageRef won't be released by ARC

Reference Link :

Create a thumbnail or image of an AVPlayer at current time

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download