Skip to content

Help with settings for low latency RTSP network stream

We would like to use vlc-unity to get as low latency as possible live stream from rtsp of IP network camera. IP cam same direct network PC. I'm getting good results using the VLC media player with these settings: image

And setting :network-caching=0

However in the Unity Editor (2019.4.19) I'm getting lots of weird behavior. Sometimes even crashing Unity.

I've modified the example MinimalPlayback script for my testing scene. Basically been playing around with the AddOption() method to see what might be working and what is breaking:

'''csharp

            _mediaPlayer.Media = new Media(_libVLC, new Uri("rtsp://192.168.10.113:554/axis-media/media.amp?channel=1&subtype=0&unicast=true"));

            // See https://wiki.videolan.org/VLC_command-line_help/ for options
            _mediaPlayer.Media.AddOption(":rtsp-user=\"root\"");
            _mediaPlayer.Media.AddOption(":rtsp-pwd=\"1234\"");
            
            _mediaPlayer.Media.AddOption(":network-caching=0");

            MediaConfiguration mc = new MediaConfiguration();
            mc.NetworkCaching = 0;
            mc.EnableHardwareDecoding = true;
            _mediaPlayer.Media.AddOption(mc);

            _mediaPlayer.Media.AddOption(":rtsp-tcp");
            _mediaPlayer.Media.AddOption(":rtsp-frame-buffer-size=250000");

            _mediaPlayer.Media.AddOption(":sout-x264-preset=\"ultrafast\"");
            _mediaPlayer.Media.AddOption(":sout-x264-tune=\"zerolatency\"");

            _mediaPlayer.Media.AddOption(":sout-x264-profile=\"high\"");
            _mediaPlayer.Media.AddOption(":sout-x264-level=\"0\"");

'''

I don't even know if I have some of these right. Are sout-x264- settings going to impact input of the stream? Are those supposed to be strings? Of the above the only ones I know are doing anything are the user, password, and network-caching. Need help on the rest. I was just trying to match was I had in VLC media player. I'm attaching the console log output. Please let me know what settings I should be using for my RTSP stream that will work to give me low latency and not crash Unity. Thank you!

ConsoleLogOutput.log