Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to combine with ready-made camera library ? #1403

Open
Menghang01 opened this issue Feb 15, 2024 · 5 comments
Open

How to combine with ready-made camera library ? #1403

Menghang01 opened this issue Feb 15, 2024 · 5 comments

Comments

@Menghang01
Copy link

https://github.com/CainKernel/CainCamera

Hello Pedro, I discovered this camera filter library along with your rtmp publish package. May I know the step to combine these two to work together ?

Thank you.

@pedroSG94
Copy link
Owner

Hello,

Maybe you can try this way:
pedroSG94/RTSP-Server#110

You can create your own VideoSource using that library. You will need study that library to check the way to render a SurfaceTexture

@Menghang01
Copy link
Author

Screenshot 2024-02-16 at 10 24 03 in the morning

I spent some time looking at the library and found this callback function for rendering the surface texture. May I know what is the next step ?
Also, the texture view that is created from the filter library is already set up with EGL. Is there any way to pass the texture view straight into your library so that it can be sent to the rtmp server ?

@pedroSG94
Copy link
Owner

pedroSG94 commented Feb 16, 2024

Hello,

I spent some time looking at the library and found this callback function for rendering the surface texture. May I know what is the next step ?

Now, you need create your own VideoSource as described in the issue I shared you.
You have a code example using cameraX library here:
https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/rotation/CameraXSource.kt

Also, the texture view that is created from the filter library is already set up with EGL. Is there any way to pass the texture view straight into your library so that it can be sent to the rtmp server ?

I provide you the SurfaceTexture to render in the start method of VideoSource that you need implement.
Use the reverse way (set a SurfaceTexture to my library) has no sense because you can't listen and get video data from a SurfaceTexture if it is not created by your own Gl context (this is the way OpenGl works). So the way is:

You have a library that need video data to work (RootEncoder) and a library that generate video data (camera1, camera2, camerax, MediaPlayer, CainCamera, etc)
The idea is that my library create a SurfaceTexture to obtain video data needed from the library that can generate it. So the library that generate video data, need render the SurfaceTexture to work.

@Menghang01
Copy link
Author

Hello Pedro. I spend the last few days understanding the library and try to create the video source as you mentioned. The problem I am facing right is only audio packet is being sent while the log related to VideoEncoder being prepared and started can be seen in the logcat . May I know what could be the possible reasons for video packet not being sent ?

@pedroSG94
Copy link
Owner

Hello,

Maybe the problem is that you are not rendering the SurfaceTexture provided by VideoSource correctly.
Video packets are generated each time SurfaceTexture is renderer with a new frame.
A way to test it is use startPreview method with a normal SurfaceView or TextureView and then the video should be renderer in that view

Can you show me your VideoSource code? Maybe I can help you more this way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants