iPhone 4 AVFoundation:同时从前置和后置摄像头捕获
我想知道是否可以使用 AVFoundation 框架同时从两个摄像头进行捕获。具体来说,我的问题是前后 AVCaptureDevices 是否可以同时处于活动状态。
目前我知道 AVCaptureSession 实例只能支持一个输入(和输出)。我创建两个 AVCaptureSession,将前置摄像头设备连接到一个,将后置摄像头设备连接到另一个,然后将会话的输出指向不同的 SampleBufferDelegate 函数。我看到的是,一个委托函数在几帧内处于活动状态,然后另一个函数接管。如果正在使用另一个摄像头设备,AVFoundation 似乎会以某种方式关闭该摄像头设备。任何人都可以证实这一点或分享他们关于这个主题的经验吗?
提前致谢
I was wondering if it was possible to capture from both cameras simultaneously using AVFoundation framework. Specifically, my question is whether both front and rear AVCaptureDevices can be active at the same time or not.
Currently I know that an AVCaptureSession instance can support only one input (and output). I create two AVCaptureSessions, attach front camera device to one and rear to other, I then point the outputs of the sessions to different SampleBufferDelegate functions. What I see is that one delegate function is active for a few frames, then the other takes over. It seems as if AVFoundation somehow turns off a camera device if another one is being used. Can anyone confirm this or share their experiences regarding this subject?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
回答我自己的问题:
(根据我的测试,每次切换大约需要 500 毫秒)
来源:https://devforums.apple.com/消息/369748#369748
Answering my own question:
(Takes about 500ms per switch according to my tests)
Source: https://devforums.apple.com/message/369748#369748
从 iOS 13 开始,这是可能的。现在可以使用多摄像头将前置摄像头和后置摄像头的输出同时记录到单个影片文件中
https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/avmulticampip_capturing_from_multiple_cameras
From iOS 13, it's possible. One can now simultaneously record the output from the front and back cameras into a single movie file by using a multi-camera
https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/avmulticampip_capturing_from_multiple_cameras