Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Android, is it possible to change Camera (from front to back) and still keep recording?

That's my question :). If I start recording using the Front Camera with the MediaRecorder and then switch to the back camera, is it possible to keep recording using the same video file? Also, is it possible to record both cameras at the same time?

like image 961
StackOverflowed Avatar asked Mar 19 '14 14:03

StackOverflowed


People also ask

Can I record with front and back camera same time Android?

You can use Director's View by itself (with no selfie camera) or with Dual recording, which lets you simultaneously record with the rear camera and selfie camera at the same time. Director's View also gives you the option to switch between the rear camera lenses.

How do I change the camera direction while recording?

Tap on the Camera icon at the bottom. On Android, go to the Video option. Press the Capture icon to begin recording. Then double-tap anywhere on the screen to flip the camera.


1 Answers

You can do it on Nexus9 with camera2 api. (Nexus5 can't open 2 cameras at the same time)

  • Create 2 Gl contexts(Shared) and 2 texture buffers.
  • Create a TextureView for previewing.
  • Create a MediaRecoder for recording.
  • Open front and back camera.
  • Make repeating request that output target is texture buffer.
  • Render scene with 2 textures to TextureView's surface for each frame.
  • Render scene with 2 textures to MediaRecoder's surface for each frame.

You can switch to each camera by changing render object. You can also render both images in same video using alpha-blend, transform, scaling, etc. by 30fps

like image 179
Joe Mizuno Avatar answered Sep 20 '22 09:09

Joe Mizuno