Sunday, 27 October 2019

AVVideoCompressionPropertiesKey crash

I am doing real time video recording using AVAssetWriter and AVCaptureVideoDataOutput. I see many crash reports on user devices but can not reproduce it on any of my devices. I need info on what could be going wrong in code below. It happens probably because typecast of NSDictionary to [String:AnyObject] fails.

In the class I have:

private var videoOut: AVCaptureVideoDataOutput?

And then in a function, I do this:

  var recommendedSettings:[String:AnyObject]?

  recommendedSettings = videoOut.recommendedVideoSettings(forVideoCodecType: AVVideoCodecType.hevc, assetWriterOutputFileType: AVFileType.mov) as? [String : AnyObject]

  if let recommendedSettings = recommendedSettings {

  /* crashes here */
  var compressionSettings = recommendedSettings[AVVideoCompressionPropertiesKey] as! [String:AnyObject]


  }

What is the assumed return type for dictionary returned by AVVideoCompressionPropertiesKey in Swift?



from AVVideoCompressionPropertiesKey crash

No comments:

Post a Comment