title: Cannot generate Video Thumbnails with Cache in Swift
body: <p>Been struggling to make it work. I am generating the Video Thumbnails but it's loading really heavily in a collection view. I would like to cache them and I can not find a solution.</p>
  
  <p>This is the code I am using:</p>
  
  <pre><code>func previewImageFromVideo(url:NSURL) -&gt; UIImage? {
  
  
      let asset = AVAsset(url: url as URL)
      let imageGenerator = AVAssetImageGenerator(asset:asset)
      imageGenerator.appliesPreferredTrackTransform = true
      imageGenerator.maximumSize = CGSize(width: 250, height: 120)
  
      var time = asset.duration
      time.value = min(time.value,2)
  
      do {
          let imageRef = try imageGenerator.copyCGImage(at: time, actualTime: nil)
          return UIImage(cgImage: imageRef)
      } catch {
          return nil
      }
  }
  </code></pre>
  
  <p>I've made them very small, but still connecting every time to the server. Please help.</p>