1

i am developing video application in that i required video cover image , that i what to select from the user,

select cover image from the user like below image

enter image description here i search many times in google for custom controller but i didn't get any result, if is there any custom controller ?? or any suggestion for that it is very helpful for me

Mitul Bhadeshiya
  • 1,280
  • 1
  • 12
  • 32

1 Answers1

1

Actully you can get Video Thumb cover image using path of video file using Bellow code or you can get all frame of video file. But there Apple Not provide any view-controller for choose cover image Thumb for video. you have to create Manually Time at thumbnailImageAtTime or create you own that type of view and get thumb image using Bellow code. Hope that useful.

-(void) getAllImagesFromVideo
{
   imagesArray = [[NSMutableArray alloc] initWithCapacity:375];
   times = [[NSMutableArray alloc] initWithCapacity:375];

   for (Float64 i = 0; i < 15; i += 0.033) // For 25 fps in 15 sec of Video
   {
       [times addObject:[NSValue valueWithCMTime:CMTimeMakeWithSeconds(i, 60)]];
   } 

   [imageGenerator generateCGImagesAsynchronouslyForTimes:times completionHandler:^(CMTime requestedTime, CGImageRef image, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error) {
       if (result == AVAssetImageGeneratorSucceeded)
       {
           [imagesArray addObject:[UIImage imageWithCGImage:image]];
           CGImageRelease(image);
       }
   }];
}

Above code Ref from Get all frames of Video IOS 6 Here you have all frame image of you video. so create you own view-Controller as you mention image in to your question create view-controller like above and set all image in to horizontal scroll-view and select any for your cover image else you can get particular image from time using Bellow code directionally .

-(UIImage *)getThumbNail:(NSString*)stringPath
{
    NSURL *videoURL = [NSURL fileURLWithPath:stringPath];

    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

    UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

    //Player autoplays audio on init
    [player stop];

    return thumbnail;
}
Community
  • 1
  • 1
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • you are not add any code from video file path in method -(void) getAllImagesFromVideo so how get the video images ??? – Mitul Bhadeshiya Apr 14 '14 at 07:33
  • check http://stackoverflow.com/questions/17436552/get-all-frames-of-video-ios-6 and also check http://stackoverflow.com/questions/4199879/iphone-read-uiimage-frames-from-video-with-avfoundation – Nitin Gohel Apr 14 '14 at 07:44