Code Monkey home page Code Monkey logo

Comments (5)

alexcohn avatar alexcohn commented on June 5, 2024

First of all, you need a compatible device. Many devices with Snapdragon SoC are capable, see https://www.qualcomm.com/news/onq/2015/10/30/snapdragon-dual-cameras-capture-photos-first-adjust-focus-later.

Then, camera2 API lets you open the two devices.

Finally, you can encode the video as a single combined stream (e.g. Picture in Picture), or as separate video streams.

There is nothing special that you must do to produce RTMP.

from grafika.

Arslanmajeed270 avatar Arslanmajeed270 commented on June 5, 2024

First of all, you need a compatible device. Many devices with Snapdragon SoC are capable, see https://www.qualcomm.com/news/onq/2015/10/30/snapdragon-dual-cameras-capture-photos-first-adjust-focus-later.

Then, camera2 API lets you open the two devices.

Finally, you can encode the video as a single combined stream (e.g. Picture in Picture), or as separate video streams.

There is nothing special that you must do to produce RTMP.

@alexcohn thanks for the reply. Can you tell me how can i encode both stream into single stream so that i can stream through rtmp.

from grafika.

alexcohn avatar alexcohn commented on June 5, 2024

how can i encode both stream into single stream

First, you configure the two streams to be of the same width. Then, you create a stream of this width, and the height that is a sum of the two, and a pixel buffer that is enough to hold this. You copy the frame pixels of the back camera to the upper half, the pixels of the front camera to the lower part. When both parts are ready, you send the frame to the encoder (using MediaCodec). The encoded frame is sent to RTMP same as if you had a single camera.

from grafika.

Arslanmajeed270 avatar Arslanmajeed270 commented on June 5, 2024

how can i encode both stream into single stream

First, you configure the two streams to be of the same width. Then, you create a stream of this width, and the height that is a sum of the two, and a pixel buffer that is enough to hold this. You copy the frame pixels of the back camera to the upper half, the pixels of the front camera to the lower part. When both parts are ready, you send the frame to the encoder (using MediaCodec). The encoded frame is sent to RTMP same as if you had a single camera.

I have did exact same but the problem is that i want back camera should be full width and front camera should be overlap on it so that it look like picture in picture.

from grafika.

alexcohn avatar alexcohn commented on June 5, 2024

So, you have no choice but to copy one frame over the other (Y plane separate from UV plane, line by line).

from grafika.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.