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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With