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