Note that there are some explanatory texts on larger screens.

plurals
  1. POI cannot get a precise CMTime for Generating Still Image from 1.8 second Video
    primarykey
    data
    text
    <p>Every time I try to generate a still frame from my video asset, it is generated at a time of 0.000.. seconds. I can see this from my log message. The good thing is that I can get the image at time 0.000.. to show up in a UIImageView called "myImageView." I thought the problem was that AVURLAssetPreferPreciseDurationAndTimingKey was not set, but even after I figured out how to do that, it still does not function..</p> <p>Here is what I have..</p> <p>time, actualTime, and generate are declared in the Header</p> <pre><code>NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/videoTest4.m4v"]]; //UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil); NSURL *url = [NSURL fileURLWithPath:path]; NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]; AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:options]; Float64 durationSeconds = CMTimeGetSeconds([asset duration]); generate = [[AVAssetImageGenerator alloc] initWithAsset:asset]; NSError *err = nil; time = CMTimeMake(600,600.0); CGImageRef imgRef = [generate copyCGImageAtTime:time actualTime:&amp;actualTime error:&amp;err]; UIImage *currentImg = [[UIImage alloc] initWithCGImage:imgRef]; myImageView.image = currentImg; NSLog(@"The total Video Duration is %f",durationSeconds); NSLog(@"The time I want my image is %f",CMTimeGetSeconds(time)); NSLog(@"The actual time my image was take was %f",CMTimeGetSeconds(actualTime)); </code></pre> <p>And my Console reads.. </p> <p>2011-04-28 18:49:59.062 videoTest[26553:207] The total Video Duration is 1.880000</p> <p>2011-04-28 18:49:59.064 videoTest[26553:207] The time I want my image is 1.000000</p> <p>2011-04-28 18:49:59.064 videoTest[26553:207] The actual time my image was take was 0.000000</p> <p>..........................</p> <p>Thank you guys so much in advance.. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload