ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.

Home Page:https://ossrs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

APPLICATION: HTTP API get the number of frames received or sent for FPS.

winlinvip opened this issue · comments

To get the FPS, SRS must provide the number of frames, user can get it from HTTP API.
For example, the number of frames is 1000, duration 100s, then the FPS is 10=1000frames/100s.

amazing

Generally, frame rate calculation requires calculating a certain time difference, such as 10-second fps, or 30-second fps, or 300-second fps, to reflect the sending and receiving situation of the stream.
For example, data can be collected every 10 seconds (the minimum statistical interval):

In the first 10 seconds, the number of frames obtained is 1000.
In the second 10 seconds, the number of frames obtained is 1500.
In the third 10 seconds, the number of frames obtained is 1700.

So, for the first 10 seconds, the fps=(1500-1000)/10=50fps.
For the second 10 seconds, the fps=(1700-1500)/10=20fps.
For the first 30 seconds, the fps=(1700-1000)/30=23.33fps.

If the stream itself is 25FPS (original frame rate), then for the first 10 seconds, it is possible that the gop cache sent a higher frame rate. For the second 10 seconds, there is actually stuttering and the frame rate is insufficient. From 30 seconds onwards, the frame rate is slightly lower.

How to determine the original frame rate of the stream? The configuration on the encoder can be checked by accessing the encoder's interface or through the business system. The frame rate provided by SRS is the distributed frame rate.

TRANS_BY_GPT3

Good

The time interval for updating Frames data is configured as follows:

        # the normal packet timeout in ms for encoder.
        # default: 5000
        normal_timeout      5000;

The update can be done by setting the timeout for receiving packets. It should not be set too short, otherwise the encoder will be considered timed out, usually 3-5 seconds or more.

The calculation of FPS itself is not real-time because when TCP sends packets, it is more like pulses and not sending one packet at a time, but rather in batches. Therefore, adjusting this time interval to 1 second does not make sense, and it will not affect the calculation of FPS even if it is set to 3-5 seconds or more.

TRANS_BY_GPT3

Can I get duration of live from HTTP API, and what live_ms mean?