Skip to content

Question about RTSP fps #1792

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

Open
oUp2Uo opened this issue Apr 2, 2025 · 6 comments
Open

Question about RTSP fps #1792

oUp2Uo opened this issue Apr 2, 2025 · 6 comments

Comments

@oUp2Uo
Copy link

oUp2Uo commented Apr 2, 2025

Hi, I have a question about RTSP fps.
I am using Camera2Source as video source, mediamtx on PC as server, and VLC on PC to view the stream.

I want to set a lower fps to reduce the data size, so I set fps like this:
call genericStream.getGlInterface().forceFpsLimit(fps) before prepareVideo(width, height, vBitrate, fps, iFrameInterval, rotation).
And I find that no matter what fps number do I set, VLC will always get FPS 29.97.

Image

But the parameter seems works (video is not as smooth as 30 fps).
I think it is not a VLC's bug in showing RTSP fps. I tried to use FFMPEG to push a 24fps file, and VLC showed 24 correctly.

So does this mean smartphone is pushing same images to fit 29.97, or just some parameter is not setting right cause VLC always showing 29.97?

Thank you.

@pedroSG94
Copy link
Owner

Hello,

Maybe the problem is in metadata,
I will check it and report back

@pedroSG94
Copy link
Owner

Hello,

I was checking the case and this seems that the problem is related with the SPS generated, in Android the SPS never add a value named "vui_parameters_present_flag", this value is optional and contain information about the video fps.
Using ffmpeg this value is present and the server can handle the fps metadata.
So, it is not a bug at all, the fps is 30 because this value is never reported and the server insert this value by default.

I will check if I can insert fps value in the RTSP ANNOUNCE

@oUp2Uo
Copy link
Author

oUp2Uo commented Apr 3, 2025

Hi @pedroSG94 ,

Thank you for the reply.

I have checked the "Statistics" tag, which has frame number count.
And I think fps setting is working.
For example, I set 6 fps on phone, then I count about 20 seconds manually, and it is about 300 frames displayed on VLC.
So it is about 15 fps (which is not equal with expected 6 fps), slower than 30 fps.
Maybe 15fps is the lowest supported frame rate on this resolution?
Since now Camera2Source does not have a interface to read supported fps on each resolution, I could not verify this.
Anyway, fps setting seems work.

@pedroSG94
Copy link
Owner

pedroSG94 commented Apr 7, 2025

Hello,

I'm not sure the way you are testing but I comfirmed that the fps is working correcly.
You can check the fps send to the stream using fps callback:

genericStream.setFpsListener { fps ->
        //callback each second that report the fps value
}

I only set the fps value in prepareVideo method (I'm using GenericStream)

genericStream.prepareVideo(width, height, vBitrate, rotation = rotation, fps = 2)

This callback count the video frames send to the protocol module (rtmp, rtsp, etc)

@oUp2Uo
Copy link
Author

oUp2Uo commented Apr 8, 2025

Hi @pedroSG94

Thanks for the reply.
I also think fps setting is working, but only information VLC showing about fps is wrong (which as uploaded screenshot image on top).

Update 20250409:
I have tested with fps callback, it could be set <15, like 2 fps.
And I confirmed VLC again about the fps.
Last time I count number in 'Video - frames', but actually should count 'Video - blocks'.
As you can see in this screenshot video, it it about 2 fps.
https://github.com/user-attachments/assets/5e3dfb16-1700-4186-84d2-6d63b0bce983

@pedroSG94
Copy link
Owner

Yes,

As commented before it is expected because the fps value is provided by SPS but this value is optional in the SPS. In Android this value seems that never is created so the fps is unknown. In this case the server seems that set the default value (30fps).

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