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

不问归期 提交于 2020-01-19 11:15:08

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/22508276/in-android-is-it-possible-to-change-camera-from-front-to-back-and-still-keep

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!