I just create my own custom video player using AVFoundation
library's AVPlayer* myPlayer. Now I want to capture images for bookmarks of video from running playing video on UIButton
click action
. On click UIButton
it take snapshot of player screen and store in document directory.
Please suggest me how to do it?
Thank you in advance.
Asked
Active
Viewed 771 times
2

Raj Upadhyay
- 25
- 1
- 11
-
Possible duplicate of [Create a thumbnail or image of an AVPlayer at current time](http://stackoverflow.com/questions/15360721/create-a-thumbnail-or-image-of-an-avplayer-at-current-time) – Vin May 03 '16 at 05:35
-
Help others reproduce the problem, if your problem is with code you've written, you should include some. – user861594 May 31 '16 at 03:16
2 Answers
0
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 :

Community
- 1
- 1

Payal Maniyar
- 4,293
- 3
- 25
- 51
0
AVAsset *asset = [AVAsset assetWithURL:videoURL];
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc]initWithAsset:asset];
imageGenerator.appliesPreferredTrackTransform=TRUE;
CGImageRef imageRef = [imageGenerator copyCGImageAtTime:player.currentTime
actualTime:NULL error:NULL];