24

I know this question has been asked many times before. I had looked for it over a year ago but didn't find anything so posting this question again to gather if there are any new thoughts/ approaches or hacks.

I want to be able to capture video from both cameras (front and back) in an android device.

My only thought as of now is to some how switch between front and back every 0.1 sec, however I have never been able to code this. Any help from anyone on this, please.

Also another thought is - videos are generally captured at 15 or 30 frames per second. Assume it is at 30 frames per second. What if there is a way to alternate these frames to front and back, then we could have 15 frames per second of front and 15 frames per second of back video. Is this possible? If yes then how? Please suggest. What happens to the audio? Maybe we could restrict audio to only one of the video recordings (front or back).

axs
  • 1,156
  • 1
  • 10
  • 15
  • Are you having this problem? --> http://stackoverflow.com/questions/7215230 – Robert Harvey Jul 10 '12 at 19:06
  • Switching between cameras takes too long for this to work. Simultaneous use of both cameras is impossible by design of CameraService at the moment – Tomasz Niedabylski Jul 10 '12 at 19:22
  • I wouldn't go so far as "impossible" - I'd expect that on at least some devices that you can bypass the `Camera` class and write native code to talk to the device drivers. Of course, this is only an option for a device manufacturer willing to write device specific code. – Jon Shemitz Jul 11 '12 at 22:56

3 Answers3

8

It's possible on the HTC m8, the OnePlusOne and the Motorola Nexus 6, as far as I have tested. Many more phones might support it, but you just have to test on the phones and see if the app crashes or not.

You create a camera object for each available camera and have each attach to the preview callback.

-edit- So far I've found that this works on Snapdragon 801 based phones. Dunno if all of them do it or what other SOCs support it, but that's what I've found so far.

MacD
  • 783
  • 7
  • 23
  • 1
    Do you have some sample code by any chance (Github?) Once they've attached to the preview callback can you record both simultaneously? – peoplesparkresident Apr 25 '15 at 23:09
  • 4
    Sorry, but I don't think my work will allow me to post the code :) Maybe I'll put a tutorial together at one point, because I have had to pull a lot of almost-correct-but-not-really information together and work out how to do it right. As for recording both camera's, yes you can, but you have to add a check to see which camera is calling the callback. Now that I think of it, you might even be able to give each it's own callback, but that might add a lot of overhead and thus might not be worth it. – MacD Apr 27 '15 at 01:15
  • 1
    Thank you. If you do put together a tutorial that would be really helpful, or even a few links to the "almost-correct-but-not-really" resources you used and then a few pointers, that would be much appreciated. – peoplesparkresident Apr 27 '15 at 07:20
  • Thank you. It is true about only devices on Snapdragon 801based supported this future. – Sirelon Oct 02 '15 at 11:50
  • "It's possible on the HTC m8, the OnePlusOne and the Motorola Nexus 6, as far as I have tested" - is there any app in the play store that is already doing that? – Thomas Dec 19 '16 at 02:21
6

It is possible but so far, only with the upcoming Samsung Galaxy S4.

It has a dual-camera feature but who knows whether it's hardware-dependant or a software-modification by Samsung, at this stage.

Dual Camera - See both sides of the story.

Hopefully it can be ported to other phones, if it's just software.

Alastair
  • 6,837
  • 4
  • 35
  • 29
5

You can't use both simultaneously and switching between each camera every 0.1 seconds is not going to work well. Acquiring and releasing the camera object is pretty expensive and this just isn't going to pan out well.

LuxuryMode
  • 33,401
  • 34
  • 117
  • 188
  • 1
    Doesn't seem to be. (That's why I'm on stackoverflow right now.) `release()` / `open()` is taking 900 to 1000 msecs *per* camera on a Galaxy Nexus, though other threads show that that time depends on the hardware. `unlock()` / `open()` gives you the same 'only one Camera at a time' exception that `release()` / `open()` does. – Jon Shemitz Jul 11 '12 at 22:51
  • 1
    Thanks. Hope there is some way this can be done sometime in the near future. – axs Aug 06 '12 at 16:04