Can the iPhone4 record from both front and rear-facing camera at the same time?
Asked Answered
S

2

12

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?

Thanks :)

EDIT: 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.

Sconce answered 12/10, 2010 at 23:23 Comment(3)
Do you mean the front and the rear facing camera or the front facing camera and the incoming persons camera?Onus
Apologies... Front and rear... i.e. both cameras at once.Sconce
I'm interested in this as well, please post anything you discover and I'll do the same!Tapioca
C
13

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:

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

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.

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.

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.

Consideration answered 1/3, 2011 at 16:31 Comment(1)
Do you still have this code lying around to test iOS5, 6, or 7? :)Commoner
V
5

It appears to be possible to record from multiple video inputs using the AVFoundation API. According to the documentation, multiple AVCaptureDevice inputs can be used in an AVCaptureSession. In an iPhone 4 this means that a session could have both AVCaptureDevices for both cameras. In practice, it might not be feasible. I haven't tried it so I can't tell with certainty.

I don't think the standard UIImagePickerController can be used to record from both at the same time.

Verbiage answered 1/3, 2011 at 16:10 Comment(1)
Yeah, you'd almost certainly have to use CoreMedia. A good starting point .. #10199521 and adcdownload.apple.com//videos/wwdc_2010__sd/…Graiae

© 2022 - 2024 — McMap. All rights reserved.