Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:27:14+00:00 2026-05-28T08:27:14+00:00

I am selecting video clip from library. And i want to create thumbnail image

  • 0

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;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:27:15+00:00Added an answer on May 28, 2026 at 8:27 am

    Try using AVAssetImageGenerator instead. Apple discusses using AVAssetImageGenerator to create thumbnails here. Here is sample code, which grabs a single thumbnail image. You will need to include the AVFoundation framework. And also add CoreMedia framework

    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:vidPath options:nil];
    AVAssetImageGenerator *gen = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    gen.appliesPreferredTrackTransform = YES;
    CMTime time = CMTimeMakeWithSeconds(0.0, 600);
    NSError *error = nil;
    CMTime actualTime;
    
    CGImageRef image = [gen copyCGImageAtTime:time actualTime:&actualTime error:&error];
    UIImage *thumb = [[UIImage alloc] initWithCGImage:image];
    CGImageRelease(image);
    [gen release];
    

    One more solution is

    -(void)generateImage
    {
        AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:self.url options:nil];
        AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
        generator.appliesPreferredTrackTransform=TRUE;
        [asset release];
        CMTime thumbTime = CMTimeMakeWithSeconds(0,30);
    
        AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
            if (result != AVAssetImageGeneratorSucceeded) {
                NSLog(@"couldn't generate thumbnail, error:%@", error);
            }
            [button setImage:[UIImage imageWithCGImage:im] forState:UIControlStateNormal];
            thumbImg=[[UIImage imageWithCGImage:im] retain];
            [generator release];
        };
    
        CGSize maxSize = CGSizeMake(320, 180);
        generator.maximumSize = maxSize;
        [generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
    
    }
    

    Or

    ALAsset
    display image from URL retrieved from ALAsset in iPhone

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am selecting rows from a table, but some of the columns are a
I'm trying to launch embedded Youtube videos from a UIWebView, but get this error
I've written a plugin which inserts photos/video from a popup lightbox into TinyMCE. This
I have the following code; String[] projection = { MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DATA }; //String selection
I have this pseudo code to display different content based on user selection, which
I have written some code that works pretty well, but I have a strange
Am developing a application which is only selecting video form local photo library and
I'm trying to change the source of a video from selecting a link. So
i have the problem with the select the image from UIImagePickerController in ipad in
I am selecting from a table that has an XML column using T-SQL. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.