简体   繁体   中英

Use both back and front camera for the same MediaRecorder session Camera2API

I need to make a video capturer which records something and then saves the file to the disk.

I succeeded in making it work with either back camera and front camera separately but i can't figure out how to make them work together and switch between them the same way the native app does while recording.

I've read that back and front camera are separate devices but I was wondering if there is a possibility to make them work together or the only thing I can do is that when I switch between the cameras to save the current file, start a new media recorder session and record another file and to merge them after I finish.

Thanks

On many modern Android phones the two cameras can work in parallel. You cannot use MediaRecorder to work with such stream, because it can either work with input from one camera (and you have no control over the recording until you stop it), or record a Surface .

Well, in principle you could draw the frames from the two cameras on the same Surface and connect this Surface to a MediaRecorder , but it would not work smoothly.

What you can do, is receive the frames from the two cameras, merge them together to receive a composite frame, and pass these frames to MediaCodec , and then – to MediaMuxer , similar to the camera recording example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM