iPhone4可以同时从前置摄像头和后置摄像头记录吗? [英] Can the iPhone4 record from both front and rear-facing camera at the same time?

查看:329
本文介绍了iPhone4可以同时从前置摄像头和后置摄像头记录吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个应用程序。出现的一个有趣的想法是同时从前置摄像头和facetime相机记录。任何人都知道这是否可行?

I am researching for an application at the moment. One of the interesting ideas that came up were to record from both front facing camera and the facetime camera at the same time. Any of you know if this is feasible?

感谢:)

编辑:
前后摄像头。我想同时从两个摄像机记录到两个独立的流。我希望我有一点清楚。

I mean to say front and rear cameras. I want to record from both cameras at once to two separate streams. I hope I'm a little clearer.

推荐答案

这是API允许的。我尝试了在运行最新的iOS 4.2.1的iPhone 4上的三种方法。

It's something the API does allow for. I tried three approaches on an iPhone 4 running the latest iOS, 4.2.1.

首先,我尝试使用一个捕获会话作为输入连接两个视频设备。附加第二个设备会产生异常:

Firstly, I tried using a single capture session with both video devices attached as inputs. Attaching the second device produces an exception:


由于未捕获而终止应用程序
exception
'NSInvalidArgumentException'
' * 多个音频/视频
AVCaptureInputs目前不支持

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* Multiple audio/video AVCaptureInputs are not currently supported.'

其次,我尝试设置两个不同的会话,每个只有一个摄像头,并同时启动它们。这导致第一个会话报告帧大约一秒钟,但一旦第二个开始自己的意志的第一次停止。发送startRunning的顺序决定了哪些会话最终会强制另一个会话。

Secondly, I tried setting up two different sessions, each with only one camera and starting them at the same time. This caused the first session to report frames for about a second, but as soon as the second starts the first stops of its own volition. The order in which you send 'startRunning' dictates which of the sessions ultimately manages to force the other out.

最后,我尝试了一个简单的乒乓方法。所以我创建两个会话,开始第一个,一旦它报告一个框架,停止它,并启动第二个。然后停止第二个并开始第一个,无限期。令人遗憾的是,请求会话开始和接收第一帧之间的延迟使我每两秒钟左右一帧。

Finally, I tried a simple ping pong approach. So I create two sessions, start the first and as soon as it reports a frame, stop it and start the second. Then stop the second and start the first, ad infinitum. Sadly the latency between requesting a session start and receiving the first frame left me with about one frame every two seconds.

当然,我可能在我的代码错误,但我'倾向于说,这是不可能在当前的硬件或操作系统。我将挂钩AVCaptureSession通知,以查看我是否明确说明为什么停止并更新此帖。

Of course it's possible I erred in my code, but I'm inclined to say that it's not possible on the current hardware or OS. I shall hook the AVCaptureSession notifications to see if I'm given an explicit reason why one stops and update this post.

添加:我的程序只接收AVCaptureSessionDidStartRunningNotification通知,一个从每个捕获会话。停止的程序不会报告错误,中断或其他停止。我也无法找到我的代码的问题,如对象或分派队列重用,可能会导致此问题。

Additions: my program receives only the AVCaptureSessionDidStartRunningNotification notifications, one from each capture session. The one that halts doesn't report an error, interruption or other stoppage. I am also unable to find an issue with my code, such as an object or dispatch queue reuse, that might conceivably cause this problem.

这篇关于iPhone4可以同时从前置摄像头和后置摄像头记录吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆