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 7703467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:27:56+00:00 2026-05-31T23:27:56+00:00

I am using AVFoundation framework in my iPad app to record videos.When recording of

  • 0

I am using AVFoundation framework in my iPad app to record videos.When recording of a video is completed, I create a thumbnail image for same video using AVFoundation.But if I record two videos without much time delay in between then thumbnail is not created properly.Clearly it’s taking some delay.How to avoid that or at least how can I know when the thumbnail of previous video has got created completely so that I can show some ‘Wait’ symbol to the user for that time period?

Please help as I am having no clue to resolve the issue.

//delegate method which gets called when recording ends.
//Here I create the thumb and store it in self.thumb
-(void)recorder:(AVCamRecorder *)recorder recordingDidFinishToOutputFileURL:(NSURL *)outputFileURL error:(NSError *)error
{
    self.thumb=nil;
    AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:outputFileURL options:nil];
    AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
    generator.appliesPreferredTrackTransform=TRUE;
    [asset release];
    CMTime thumbTime = CMTimeMakeWithSeconds(0,1);

    AVAssetImageGeneratorCompletionHandler handler = ^(CMTime requestedTime, CGImageRef im, CMTime actualTime, AVAssetImageGeneratorResult result, NSError *error){
        if (result != AVAssetImageGeneratorSucceeded) {
            NSLog(@"couldn't generate thumbnail, error:%@", error);
        }

         self.thumb=[UIImage imageWithCGImage:im];

        [generator release];
    };

    CGSize maxSize = CGSizeMake(320, 180);
    generator.maximumSize = maxSize;
    [generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];

    if ([[UIDevice currentDevice] isMultitaskingSupported]) {
        [[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
    }       

    if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {
        [[self delegate] captureManagerRecordingFinished:self];
    }
}


[self copyFileToDocuments:outputFileURL];
}


//Save video and thumbnail to documents
- (void) copyFileToDocuments:(NSURL *)fileURL
{
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd_HH-mm-ss"];
NSString *destinationPath = [documentsDirectory stringByAppendingFormat:@"/output_%@.mov", [dateFormatter stringFromDate:[NSDate date]]];
[dateFormatter release];
NSError *error;
if (![[NSFileManager defaultManager] copyItemAtURL:fileURL toURL:[NSURL fileURLWithPath:destinationPath] error:&error]) {
    if ([[self delegate] respondsToSelector:@selector(captureManager:didFailWithError:)]) {
        [[self delegate] captureManager:self didFailWithError:error];
    }
}
else
{
    destinationPath=[[destinationPath lastPathComponent]stringByDeletingPathExtension];
    [self saveImage:self.thumb withName:destinationPath];
}

}

    //Method Where I save  self.thumb in app documents
-(void) saveImage:(UIImage*)image withName:(NSString*)fileName
{
NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];
   //Save Image
NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",fileName]];

[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];

}

Above is my code.
But self.thumb is not getting properly saved if I don’t give delay in two recordings.

  • 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-31T23:27:57+00:00Added an answer on May 31, 2026 at 11:27 pm

    I used a different method.When user clicks ‘Record’ I first click a photo from camera and then start recording the video.Later I use the same photo as a thumbnail.

    I know this is not the best approach but the best thing is its working 😉

    Hope this helps someone with the same problem.

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

Sidebar

Related Questions

i can capture image using avfoundation.framework as shown in AVCam Demo but i want
I'm trying to create an app which plays videos from a file using AVFoundation
Im trying to record video using AVFoundation I can save images but not video.
I am reading a video file using AVFoundation framework and getting the image buffers
I am trying to implement video capture in my app using AVFoundation. I have
I am using AVFoundation to record video on IOS 5. I would like the
I using avfoundation to record video from my device and going to use imagepicker
I am trying to record video using AVFoundation. When I add video input only
iam using AVFoundation Framework to play mp3 file ,everything works great ، i have
I'm creating an iphone app using xcode 4.2, and trying to use the AVFoundation

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.