Comments (5)
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.
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.
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)
- RTS stream url pattern failed HOT 1
- Fast moving objects are blurred HOT 1
- The issue when using RtmpFromFile and SurfaceFilterRender together. HOT 3
- cannot set bitrate in displayBase to increase the video quality HOT 4
- IPv4 and IPv6 HOT 3
- RtmpCamera2 seems to have a critical memory leak issue. HOT 1
- Use G729 Audio codec instead of G711 HOT 2
- CameraX Integration HOT 53
- External UVC Camera support HOT 2
- How to dynamically add SEI extended data transmission in real time during RTSP/RTMP live streaming HOT 1
- RTSPS and self-signed certificates HOT 7
- No video when streaming in a background service and app is minimized HOT 4
- How can i use this? HOT 1
- Streaming video output blur when moving camera with CameraX API HOT 7
- How to combine with ready-made camera library ? HOT 5
- Filter Integration HOT 3
- Using av1 HOT 3
- Delaying live streaming to AWS Medialive HOT 5
- Camera recording choppy, not smooth. Min/max frame rate difference high HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rootencoder.