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

SRT: Stutter/Choppy/Glitch covert to RTMP. After converting to RTMP, there is jitter. #3164

Closed
winlinvip opened this issue Sep 2, 2022 · 2 comments · Fixed by #3186
Closed
Assignees
Labels
SRT It's about SRT protocol. TransByAI Translated by AI/GPT.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Sep 2, 2022

SRS 5.0, after coverting SRT to RTMP, the streaming is stuttering/choppy/glitch.

Replay:

  1. Start SRS 5.0 by docker. v5.0.59
  2. Publish to SRS by FFmpeg, source is doc/source.flv.
  3. Play by RTMP or FLV, the stream is stuttering/choppy/glitch.

TRANS_BY_GPT3

@winlinvip winlinvip added the SRT It's about SRT protocol. label Sep 2, 2022
@winlinvip winlinvip added this to the 5.0 milestone Sep 2, 2022
@winlinvip winlinvip changed the title SRT: Stutter/Choppy/Glitch when covert to RTMP. 转RTMP后抖动。 SRT: Stutter/Choppy/Glitch covert to RTMP. 转RTMP后抖动。 Sep 2, 2022
@xiaozhihong
Copy link
Collaborator

xiaozhihong commented Sep 2, 2022

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.
image

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.
image

TRANS_BY_GPT3

@xiaozhihong
Copy link
Collaborator

xiaozhihong commented Sep 2, 2022

There are several solutions:

  1. Open ATC, which is the absolute timestamp, so that jitter will not be enabled. However, this may cause other issues.
  2. Add a fixed offset to the timestamp of SRT, which may result in audio and video being out of sync.
  3. Use mix_correct.
  4. 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

@xiaozhihong xiaozhihong linked a pull request Sep 22, 2022 that will close this issue
winlinvip added a commit that referenced this issue Sep 22, 2022
* SRT: print warning log when audio duration too large

* Fix #3164: SRT: Choppy when audio ts gap is too large. v5.0.65

Co-authored-by: winlin <winlin@vip.126.com>
@winlinvip winlinvip changed the title SRT: Stutter/Choppy/Glitch covert to RTMP. 转RTMP后抖动。 SRT: Stutter/Choppy/Glitch covert to RTMP. After converting to RTMP, there is jitter. Jul 29, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SRT It's about SRT protocol. TransByAI Translated by AI/GPT.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants