srs
srs copied to clipboard
SRT: Stutter/Choppy/Glitch covert to RTMP. 转RTMP后抖动。
SRS 5.0, after coverting SRT to RTMP, the streaming is stuttering/choppy/glitch.
Replay:
- Start SRS 5.0 by docker. v5.0.59
- Publish to SRS by FFmpeg, source is
doc/source.flv. - Play by RTMP or FLV, the stream is stuttering/choppy/glitch.
Occasionally, certain videos will appear, such as the built-in Avatar flv in SRS.
From the observation, it appears that the timestamp of the pulled stream elapses faster than the timestamp of the pushed stream. In other words, if the stream is pushed for 10 seconds, the playback has already advanced to around 18 seconds.

Upon analyzing the code, it was found that the lack of proper interleaving of audio and video timestamps resulted in jitter correction.
After analysis, it was found that SRT streaming uses MPEG-TS payload, where audio is combined and sent in multiple packets. From this problematic video, it can be observed that 16 audio frames are combined to form a single PES packet.

TRANS_BY_GPT3
There are several solutions:
- Open ATC, which is the absolute timestamp, so that jitter will not be enabled. However, this may cause other issues.
- Add a fixed offset to the timestamp of SRT, which may result in audio and video being out of sync.
- Use mix_correct.
- Avoid caching audio when streaming.
The final choice is 4. Add the parameter -pes_payload_size 0 to FFmpeg. The command is as follows:
ffmpeg -re -i ./doc/source.flv -c copy -pes_payload_size 0 \
-f mpegts 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'
TRANS_BY_GPT3