Showing posts with label Thumbnail from video. Show all posts
Showing posts with label Thumbnail from video. Show all posts

Friday, 9 January 2015

Thumbnail from video- iOS


UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(140, -40, 200, 200)];
            AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:msg.mediaURL options:nil];
            AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
            generate1.appliesPreferredTrackTransform = YES;
            NSError *err = NULL;
            CMTime time = CMTimeMake(1, 2);
            CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
            UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];
            [img setImage:one];
            img.contentMode = UIViewContentModeScaleAspectFit;