Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understand if an AVCaptureDeviceFormat suits video recording

In an app that I'm developing I'd like to let the user choose the the resolution of video recording. Due to specification, I can't use AVCaptureSessionPreset constants.
Getting format list there are resolutions above 3000px that of course can't work for video grabbing but only for photo shooting.

AVCaptureDeviceFormat: 0x17020c830 'vide'/'420f' 3264x2448, { 2- 30 fps}, HRSI:3264x2448, fov:58.040, max zoom:153.00 (upscales @1.00), AF System:2, ISO:29.0-1856.0, SS:0.000013-0.500000

I can't find a way to see if a specific format is suitable for video recording.
The problem is that with this kind of resolution if I try to grab a video the app generates an exception saying that there is no active or enabled connection.

-[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - no active/enabled connections.

I also don't want to hardcode limits for each kind of device.
I can't also try to cap the limit to AVCaptureSessionPresetHigh because as stated in an Apple note is not the actual maximum format.
Is there a way to understand if a AVCaptureDeviceFormat is suitable for grabbing video?

like image 743
Andrea Avatar asked Apr 19 '15 14:04

Andrea


1 Answers

After setting all the connections with the selected -activeFormat check if the current AVCaptureConnection isActive or observe using KVO the property -active. If it is no the format is not available for video grabbing, if it is yes it can be used.

like image 166
Andrea Avatar answered Oct 01 '22 20:10

Andrea