pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.57k stars 779 forks source link

Unstable FPS #1493

Open jacklai24 opened 5 months ago

jacklai24 commented 5 months ago

Hi @pedroSG94 ,

I used the RtspServerCamera1 and set FPS to '10' in the prepareVideo method. I found that the FPS will be over the limit when the scene goes from dark to light. (Maybe to FPS 30) But after a while(Maybe 30 minutes), FPS will be down to the original limit.

I trace the source code. The FpsLimiter implements the FPS limit. If the Frame queue(BlockingQueue queue) accumulates a lot in the VideoEncoder quickly, will it cause such an abnormality?

Please tell me how should I deal with this problem. Thank you.

pedroSG94 commented 5 months ago

Hello,

Are you using RtspServerCamera1 with OpenGlView? I recommend you this way because the fps is calculated in a better way using OpenGlView because I can control the render properly this way. FpsLimiter just count the number of frames encoded each second and then reset the counter. So if you have: 15fps, 5fps and 10fps in 3 seconds that is fine. You should check the average, anyway, usually the value should be really close to the fps selected and more or less constant

jacklai24 commented 5 months ago

Hi @pedroSG94 ,

Thanks for your reply. I found that this situation is on the client side not previewed on my device. Do you mean that using openglview will also affect the number of frames sent by the RTSP server?

pedroSG94 commented 5 months ago

Hello,

Yes, using OpenGlView the fps affect to preview and frames sent.

Using SurfaceView or TextureView only the frames sent are affected because the fps is limited in the encoder directly. Using OpenGlView the fps is limited in the opengl render so the encoder only receive the frames that the render accept and it is more accurate because you don't have a queue in the encoder that could produce your case.

Also, OpenGlView use the GPU. This allow you get a better fps, performance and allow you use filters