Skip to content

Srt live streaming, high packet drops and retransmissions #9438

Closed

Description

@Abeja27

Operating System Info

Windows 10

Other OS

No response

OBS Studio Version

29.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/sRBmaQFKNr14xcTi

OBS Studio Crash Log URL

No response

Expected Behavior

I expected to be able to stream to a SRT server without any packet loss using a reasonable latency, the same way I have managed to do using other alternatives like FFMPEG.

Current Behavior

When I live stream, my SRT server logs that many packets are been dropped all the time.

image

After investigating, I concluded that there are many packet retransmissions requested from the server side. Retransmitted packets end up arriving to the server but with a lot of delay causing that the packets are dropped if srt latency isn't high enough. I'm testing in a local and stable network where I expect to not have any packet loss though the network. I have tested it using FFMPEG and no packet was lost at all.

This behavior is present even using low bitrates but there are few packet retransmissions so it seems to work fine unless you use a really small latency. However It becomes a serious problem when a higher bitrate is used or when there is a high cpu usage in the OBS machine. I have dropped frames even using 3 seconds delay when machine is under high cpu usage.

At first, I was pretty sure that this was happening because I was missing any SRT parameter, or maybe I had to change any buffer size, but if that's the case, I couldn't find the way.

Steps to Reproduce

As far as I know, you just have to stream to a SRT server usign high bitrate or in high cpu usage conditions. Here the most simple case I have tested:

  1. Configure the SRT server in OBS.
    srt://yourServer:4233?latency=50000&ffs=175000&send_buffer_size=120000000&sndbuf=120000000
  2. Configure video encoder to use a high bitrate. I have tested several values betweend 5000kbps and 200000kbps using x264 and NVIDIA NVENC H264 encoders.
  3. Start a SRT server. I have used the libsrt srt-live-transmit app.
    srt-live-transmit 'srt://0.0.0.0:4233?mode=listener&transtype=live&latency=50&rcvbuf=21000000' udp://:1234 -loglevel info -v
    Moreover, to record the SRT stats I have added the options -statsout stats-snd.csv -pf csv -s 200
  4. Start the stream in obs. 👍

Anything else we should know?

I have recorded SRT stats of the server side using 10.000kbps and 200.000kbps of bitrate.

OBS_20Mbps.csv
OBS_200Mbps.csv

You can see that there are more retransmissions (pktRcvRetrans field) in the second case but they are still present in the first one.

I have also tested using FFMPEG. I used the following command:
ffmpeg -f lavfi -re -i smptebars=duration=300:size=1920x1080:rate=60 -f lavfi -re -i sine=frequency=1000:duration=60:sample_rate=48000 -pix_fmt yuv420p -c:v libx264 -b:v 200000k -x264-params "nal-hrd=CBR" -bufsize 200M -g 30 -keyint_min 30 -profile:v high -preset fast -f mpegts "srt://192.168.1.103:4233?pkt_size=1316&latency=50000"
FFMPEG_200Mbps.csv

I have set similar settings to those I have used in obs and as you can see the are no retransmissions at all.

I have reproduced this in 2 Windows 10 machines using OBS 28.0.1 and 29.1.3.
Maybe is it a libsrt bug? Should I report this there?
Thanks in advance.

Activity

  1. Abeja27 commented on Aug 29, 2023

    @Abeja27
    Author

    After further investigation, I think the problem is related to how SRT packets are spaced across the time. Here is a Wireshark capture of a Obs Srt live streaming.

    image

    As you can see, the time between packets Nº 136 and 137 is 3.463 ms. And between pkt Nº 170 and 171, it is 14.507 ms. However the 34 packets from Nº137 to Nº170 are transmitted in 0.461 ms. These is pretty close to the limit of my connection speed, so maybe OBS doesn't add delay between packets at all ?

    SRT documentation states that packets should be evently spaced across all the available time in live mode:
    https://github.com/Haivision/srt/blob/master/docs/features/live-streaming.md

    How does OBS handle this? is this feature even implemented?

    Maybe I missed something and this not the actual problem, I'm sorry if that's the case. Any kind of feedback would be very appreciated. It is important for my project that SRT streaming works correctly in OBS.

  2. pkviet commented on Sep 15, 2023

    @pkviet
    Member

    Hello,
    I can't confirm your issue.
    For instance here are my stats for an SRT stream to YT:
    obs64_2023-09-15_18-04-18
    I tested extensively interop of obs against a lot of vendors / services at last SRT Plugfest and never had the sort of issues you get. I wonder if it could be an issue on your decoder's side.
    The implementation in obs follows that in FFmpeg (95% of the code is similar) so try with FFmpeg to see if you get the same issue.
    For now, I'm going to close the issue but feel free to re-open if you come up with more information.

  3. self-assigned this
    on Sep 15, 2023
  4. basisbit commented on Nov 19, 2023

    @basisbit

    For anyone else finding this in search: try if increasing the latency parameter in the srt URL which you put in the server field resolves the issue. If that works, check the network connection between your device running OBS and the server. Most likely there are bursts of packet loss or low connection speed.
    For example (with latency of two seconds):

    srt://yourServerAddress.com:123?latency=2000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions