title: Getting a thumbnail of a *.mov video IOS
body: <p>I want to get a thumbnail of videos (*.mov) which taken with iPhone/iPAD. I am trying to use AVFoundation library for this and getting this error:</p>
  
  <pre><code>couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo=0x15d90a30 {NSLocalizedDescription=Cannot Open, NSLocalizedFailureReason=This media format is not supported.}
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentDir=[paths objectAtIndex:0];
  NSString *videoPath=[documentDir stringByAppendingPathComponent:[NSString stringWithFormat:@"videos/%@.mov",videoName]];
  
  
      AVURLAsset *asset=[[AVURLAsset alloc] initWithURL:videoPath options:nil];
      AVAssetImageGenerator *generator = [[AVAssetImageGenerator alloc] initWithAsset:asset];
      generator.appliesPreferredTrackTransform=TRUE;
  
      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);
          }
          self.img.image=[UIImage imageWithCGImage:im];
      };
  
      CGSize maxSize = CGSizeMake(320, 180);
      generator.maximumSize = maxSize;
      [generator generateCGImagesAsynchronouslyForTimes:[NSArray arrayWithObject:[NSValue valueWithCMTime:thumbTime]] completionHandler:handler];
  </code></pre>
  
  <p>I recorded videos with my app and want to show a thumbnail of them.</p>