Search code examples
iosswiftxcodeavfoundationavcapturesession

iOS AVFoundation: Get AVCaptureDevice.Format's video dimensions


I'm trying to display the dimensions in which photos/video recordings can be taken to the user.

While photo dimensions are easily accessible through AVCaptureDevice.Format.highResolutionStillImageDimensions, I have no idea how I can achieve the same for videos.

I've tried the AVCaptureDevice.Format.formatDescription.dimensions property (or the .presentationDimensions(..) func), but those just gave me the following compile errors:

enter image description here Console output

Since those are available since iOS 13.0 (I believe that was Swift 5.1?), I should definitely have the API for those (especially since I can CMD + Click on them in my code), and my project should compile. Am I missing something here? Is there a better solution to get the resolution a capture device can record videos in?


Solution

  • You just need below line.That's it.

       let dimensions = CMVideoFormatDescriptionGetDimensions(format.formatDescription)