I am selecting video clip from library. And i want to create thumbnail image of it. I have applied this code. But the image appeared rotated. I want its original view.
- (UIImage*)testGenerateThumbNailDataWithVideo {
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:appDelegate.videoURL options:nil];
AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset];
NSError *err = NULL;
CMTime time = CMTimeMake(1, 60);
CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:NULL error:&err];
[generate release];
NSLog(@"err==%@, imageRef==%@", err, imgRef);
UIImage *currentImg = [[[UIImage alloc] initWithCGImage:imgRef] autorelease];
static BOOL flag = YES;
if (flag) {
NSData *tmpData = UIImageJPEGRepresentation(currentImg, 0.8);
NSString *path = [NSString stringWithFormat:@"%@thumbNail.png", NSTemporaryDirectory()];
BOOL ret = [tmpData writeToFile:path atomically:YES];
NSLog(@"write to path=%@, flag=%d", path, ret);
flag = NO;
}
return currentImg;
}