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

查看:27
本文介绍了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:

由于未捕获而终止应用例外'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天全站免登陆