Miniaturansicht von video -

Ich bin der Auswahl von video-Clips aus der Bibliothek. Und ich will zum erstellen von thumbnail-Bild. Ich habe diesen code. Aber das Bild schien gedreht. Ich will die ursprüngliche Ansicht.

- (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;
}

InformationsquelleAutor der Frage DipakSonara | 2012-01-18

Schreibe einen Kommentar