Understand if an AVCaptureDeviceFormat suits video recording

久未见 提交于 2019-12-23 08:49:51

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29730957/understand-if-an-avcapturedeviceformat-suits-video-recording

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!