Giter Club home page Giter Club logo

Comments (5)

pedroSG94 avatar pedroSG94 commented on June 2, 2024

Hello,

Do you mean with the product the stream device screen and add camera to the stream?
In that case, yes you can do it.
If you want open 2 cameras (front and back) this depend of the device model but most of device can't do it (hardware limitation)

To do the first case you can use SurfaceFilterRender like here:
https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/openglexample/OpenGlRtmpActivity.java#L297
So using RtmpDisplay (this apply to RtspDisplay and SrtDisplay) you can add a the filter and then instead of use MediaPlayer to render the SurfaceTexture, you can use Camera2ApiManager or Camera1ApiManager:

                  Camera2ApiManager camera = new Camera2ApiManager(OpenGlRtmpActivity.this);
                  camera.prepareCamera(surfaceTexture, 1280, 720, 30);
                  camera.openCameraFront();
                  //this line must be called when you don't need camera anymore (like when you remove filter or activity is destroyed)
                  //camera.closeCamera();

Remember modify setScale and setPosition of SurfaceFiilterRender as you need to keep aspect ratio with the size that you want and the position.

from rootencoder.

B1HD avatar B1HD commented on June 2, 2024

Thanks so much for the reply, that really helped me to get it working. The issue that I'm running into now is I'm transitioning to this Image with the camera overlayed on it from just the default RTMPCamera1 view and so when I add the surface texture as a filter everything appears correct and scaled properly but the camera preview is just black. I believe this is because the camera is still being used behind the filter? I can get the camera preview to show up if I switch the camera to the back camera. I'm guessing this is because when switchCamera is called it releases the camera it was using. My question is, is there anyway to release the camera that RTMPCamera1 is using without ending the preview or stream? Thanks so much in advance for any help you can provide.

from rootencoder.

pedroSG94 avatar pedroSG94 commented on June 2, 2024

Hello,

Let me know if I understand you correctly. You have a stream with camera1 as video and then you want change to a stream with screen as video and using camera1 as filter. Right?

In that case, maybe use RtmpStream is the best way. You can change video and audio sources on realtime. And that sources are releases when you replace it for other source.
You have a code example here that support change video and audio sources:
https://github.com/pedroSG94/RootEncoder/tree/master/app/src/main/java/com/pedro/streamer/rotation
In this example you can check that, the way to use RtmpStream is a bit different that others like RtmpCamera1.
You have 3 main differences:

  • You only need call prepareVideo and prepareAudio one time before start preview, stream or record so you can stop and start it multiples times after a success prepare. If you want change parameters you only need stop all and call prepare again.
  • You can add a preview with startPreview but in this case the view is set in startPreview method allowing you to use a normal SurfaceView or TextureView instead of use OpenGlView.
  • You need call release method when you finish all to make sure all is correctly released (normally you can use it in onDestroy method of an activity).

The way to add a filter is exactly the same that with RtmpCamera1

from rootencoder.

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.