在 Android 中,是否可以更改相机(从前到后)并仍然继续录制? [英] In Android, is it possible to change Camera (from front to back) and still keep recording?
问题描述
这是我的问题:).如果我开始使用前置摄像头和 MediaRecorder 进行录制,然后切换到后置摄像头,是否可以使用相同的视频文件继续录制?另外,是否可以同时录制两个相机?
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?
推荐答案
你可以在 Nexus9 上使用 camera2 api 完成.(Nexus5不能同时打开2个摄像头)
You can do it on Nexus9 with camera2 api. (Nexus5 can't open 2 cameras at the same time)
- 创建 2 个 Gl 上下文(共享)和 2 个纹理缓冲区.
- 创建一个用于预览的 TextureView.
- 创建一个用于录制的 MediaRecoder.
- 打开前后摄像头.
- 重复请求输出目标是纹理缓冲区.
- 为每一帧将具有 2 个纹理的场景渲染到 TextureView 的表面.
- 为每一帧将具有 2 个纹理的场景渲染到 MediaRecoder 的表面.
您可以通过更改渲染对象来切换到每个相机.您还可以使用 alpha-blend、transform、scaling 等以 30fps 渲染同一视频中的两个图像
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
这篇关于在 Android 中,是否可以更改相机(从前到后)并仍然继续录制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!