2

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.

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 Answers2

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 :

Create a thumbnail or image of an AVPlayer at current time

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];
Draken
  • 3,134
  • 13
  • 34
  • 54
remyr3my
  • 768
  • 1
  • 6
  • 19