title: Generating thumbnail from Video ends up always rotated in an UIImageView
body: <p>I'm using <code>UIImagePickerController</code> to select a video or an image from the user's gallery. With the photos, there's no problem, everything is displayed the way it should be. The problem comes when I'm trying to generate a thumbnail for a video. </p>
  
  <p>Basically,  the thumbnail image could end up being displayed upside down or 90 degrees to the left or right. I'm not sure why it happens. Am I  missing something or doing something wrong?</p>
  
  <pre><code>extension PostVC : UIImagePickerControllerDelegate, UINavigationControllerDelegate {
  
  func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
      if let videoUrl = info[UIImagePickerController.InfoKey.mediaURL] as? URL {
          if let thumbnail = self.generateThumbnailForImage(videoUrl) {
              self.videoUrl = videoUrl
              self.photoImageView.image = thumbnail
              self.selectedImage = thumbnail
          }
      }
      if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
          selectedImage = image
          photoImageView.image = image
          shareButton.isEnabled = true
      }
      dismiss(animated: true, completion: nil)
  }
  
  func generateThumbnailForImage(_ fileUrl: URL) -&gt; UIImage? {
      let asset = AVAsset(url: fileUrl)
      let imageGenerator = AVAssetImageGenerator(asset: asset)
      do {
          let thumbnailCGImage = try imageGenerator.copyCGImage(at: CMTimeMake(value: 1, timescale: 10), actualTime: nil) // 1 sec
          return UIImage(cgImage: thumbnailCGImage)
  
      } catch let err {
          SVProgressHUD.showError(withStatus: err.localizedDescription)
      }
      return nil
    }
  }
  </code></pre>