H264 pipeline for live streaming

Hi,

I want to stream framed readed from RealSense camera. For that I’m using EmguCv (OpenCv) and Gstreamer pipeline. I have discovered MediaMtx RTSP server and I’m using it as RTSP server.

I’m using qsvh264enc instead of x264enc because my laptop have Intel UHD620 graphics card and seems that with that my program uses GPU. I have also seen that I can set the pipeline as live with is-live.

var command = "appsrc is-live=true ! videoconvert ! queue ! qsvh264enc low-latency=true target-usage=7 ! h264parse ! rtspclientsink location=rtsp://localhost:8554/mystream";
 
var size = new Size(1280, 720);
var backends = CvInvoke.WriterBackends;
var backend = backends.FirstOrDefault(back => back.Name == "GSTREAMER");
_videoWriter = new VideoWriter(command, backend.ID, 0, fps: 30, size, isColor: true);
if (!_videoWriter.IsOpened)
{
    Console.WriteLine("Writer not opened!!");
}

With that pipeline seems to be working but only If I set network-caching in VLC to 500ms or something like that. If I let by default I’m having a noticeable latency.
What could be the best pipeline configuration in terms of latency to reduce it and show as less latency as possible in the viewer?

Thanks for your help. With regards,

With RTP/RTSP, it might be up to client to adjust latency.

Can you try gstreamer receiver such as:

gst-launch-1.0 playbin uri=rtsp://localhost:8554/mystream uridecodebin0::source::latency=0

latency 0 may work on localhost (depending on your resolution you may have to adjust udpsink/udpsrc property buffer-size, may need to set kernel max buffer UDP read/write socket size, and/or MTU)
You may also adjust to a few frames latency for UDP over LAN.