how can improve the following it works with vlc but the latency is still significant:…
- User
how can improve the following it works with vlc but the latency is still significant: server: ffmpeg -f x11grab -s 1920x1080 -i :0.0 -vcodec libx264 -preset ultrafast -tune zerolatency -f mpegts udp://192.168.100.19:1234
client - vlc udp://@//:1234
- Assistant
You're using FFmpeg to capture your desktop via
x11graband stream it over UDP to a VLC client. While your current setup works, you experience significant latency, which is typical with this type of pipeline using H.264 over UDP with MPEG-TS container.How to reduce latency in your streaming setup:
1. Adjust FFmpeg encoding parameters
- Preset and Tune: You already use
-preset ultrafastand-tune zerolatency. This is good. - GOP size (
-g): Lower GOP size reduces latency as the decoder won't wait long for intra frames.- Try adding:
-g 15(e.g., 15 frames per GOP; at 30 FPS, this is 0.5 seconds)
- Try adding:
- B-frames: Avoid B-frames for low latency.
- Add:
-bf 0
- Add:
- CRF or bitrate: You can set a fixed rate (
-b:v) to avoid excessive rate control delay.- Example:
-b:v 3000kor-b:v 5M
- Example:
- Keyint & Min-keyint: Keep
-keyint_minequal to-gif possible.
Example command update:
ffmpeg -f x11grab -s 1920x1080 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts udp://192.168.100.19:1234
2. Network considerations
- UDP is generally low-latency, but be sure your network has minimal packet loss.
- Use a higher UDP payload size if supported, to reduce packet overhead.
- Alternatively, try
-f rtp+ SDP if VLC supports it, which can be lower latency.
3. VLC client tweaks
By default VLC buffers quite a lot to smooth network jitter, increasing latency.
- Reduce VLC's network caching:
- In VLC GUI under Tools > Preferences > Input / Codecs, set Network caching (ms) to a low value, like 50 ms or 100 ms.
- Or launch VLC with:
vlc udp://@:1234 --network-caching=50
4. Consider alternate codecs/protocols for lower latency
- Codec: H.264 is efficient but adds latency. For ultra low-latency, you could try:
- MJPEG: lighter encoding, less latency, but very bandwidth-heavy.
- VP8/VP9 with Opus in WebRTC or with specialized low-latency streaming tools.
- Protocol:
- Instead of UDP/MPEG-TS, use SRT (Secure Reliable Transport) or RTP for better latency control and packet loss handling.
- FFmpeg supports SRT (
-f mpegts srt://...), VLC supports SRT as well.
Example SRT usage:
ffmpeg -f x11grab -s 1920x1080 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts "srt://192.168.100.19:1234?pkt_size=1316"On VLC:
srt://@:1234
5. Reduce resolution and frame rate
- Lowering resolution or FPS reduces encoding delay and network overhead.
- Example:
-framerate 30(default is 25 for some versions) - Or reduce resolution to 1280x720.
Summary improved command examples
Server:
ffmpeg -f x11grab -s 1920x1080 -framerate 30 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts udp://192.168.100.19:1234Client VLC:
vlc udp://@:1234 --network-caching=50
Final notes:
- Latency less than 100-200ms can be hard to achieve with pure x11grab + H264 + MPEG-TS + VLC.
- For absolute lowest latency, look into specialized low-latency streaming solutions such as:
- NVIDIA NVENC + RTSP/SRT
- WebRTC based streaming
- Professionals often use tools like
gstreamerorffmpegcombined with SRT or WebRTC with proper codec pipelines.
If you want, I can help to prepare a minimal example using SRT or another low-latency pipeline too!
- Preset and Tune: You already use
- User
expound on :
WebRTC based streaming Professionals often use tools like gstreamer or ffmpeg combined with SRT or WebRTC with proper codec pipelines.
- Assistant
Certainly! Here’s a more detailed explanation of WebRTC-based streaming and how professionals leverage tools like GStreamer, FFmpeg, SRT, and WebRTC for low-latency streaming.
1. WebRTC-based Streaming
What is WebRTC?
- WebRTC (Web Real-Time Communication) is a modern set of protocols and APIs that enables real-time audio, video, and data communication directly between browsers and devices.
- It is designed specifically for ultra-low latency streaming with end-to-end latency typically in the 100ms range or less.
- WebRTC manages NAT traversal, congestion control, adaptive bitrate, encryption (DTLS/SRTP), and low-latency packet delivery.
- Built-in codecs include VP8, VP9, H264 (optional), and Opus for audio.
Why WebRTC for low-latency streaming?
- Unlike traditional streaming with HTTP or UDP multicast, WebRTC uses peer-to-peer UDP-based communication with efficient retransmission and jitter management.
- It can adjust video quality dynamically to network conditions.
- It delivers live streams suitable for interactive uses like video calls, remote desktop, gaming, and live performance.
How to use WebRTC to stream desktop/video?
- WebRTC is complex to set up from scratch but can be integrated with existing tools.
- For a Linux/X11 desktop capture scenario:
- Capture screen/video with
ffmpegorgstreamer. - Encode video to VP8/VP9 or H264 with low-latency settings.
- Push encoded frames into a media server or WebRTC stack that handles signaling/ICE/STUN/TURN.
- Clients (usually browsers or specialized WebRTC clients) receive the live stream with minimal buffering.
- Capture screen/video with
Popular WebRTC media servers / solutions:
- Janus Gateway
- MediaSoup
- Kurento
- Jitsi
- Pion WebRTC (Go library for building custom WebRTC apps)
- Ant Media Server (commercial/open source)
These servers handle signaling, NAT traversal, retransmissions, and provide APIs to connect FFmpeg/GStreamer pipelines with WebRTC.
Example workflow:
- Capture + encode: Use ffmpeg/gstreamer to capture desktop and encode video/audio.
- Send to WebRTC server: via UDP or RTP. Some servers accept RTP input from ffmpeg.
- WebRTC server distribution: The server manages signaling and distributes streams to browsers or native clients.
- Clients: View streams in real time with minimal latency.
2. Professionals using GStreamer / FFmpeg + SRT or WebRTC for low-latency streaming
What is GStreamer?
- GStreamer is a powerful multimedia framework for building complex pipelines for audio and video capture, processing, encoding, and streaming.
- It has excellent support for many codecs and protocols, and it's very customizable.
- It supports RTP, RTSP, SRT, WebRTC plugins and can interface with hardware encoders to minimize latency.
What is SRT?
- SRT (Secure Reliable Transport) is a transport protocol optimized for live video streaming over unpredictable networks (internet/WAN).
- It provides:
- Low latency comparable to UDP.
- Packet loss recovery.
- Encryption.
- Network congestion awareness.
- SRT is suitable for long-distance transport where UDP multicast is impractical or unreliable.
Why professionals choose FFmpeg/GStreamer + SRT or WebRTC?
- They need a balance between low latency, reliability, and scalability.
- UDP + MPEG-TS is simple but lacks packet recovery and can have jitter, causing higher latency.
- SRT deals with packet loss gracefully, keeping latency low.
- WebRTC adds NAT traversal and browser compatibility, but is more complex to deploy.
- GStreamer allows fine-grained control over pipeline latency, codec parameters, network buffering, etc.
Examples of professional pipelines:
Pipeline 1: Desktop → FFmpeg (x11grab) → H.264 (ultrafast, zerolatency) → SRT → Client
- Command line example:
ffmpeg -f x11grab -s 1920x1080 -i :0.0 \ -c:v libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts "srt://receiver_ip:port?pkt_size=1316" - On receiver:
ffmpeg -i "srt://:port" -c copy output.mp4 - Many professional broadcasters use this for reliable low-latency contribution feeds.
Pipeline 2: Desktop → GStreamer → WebRTC → Browser Client
- GStreamer has dedicated
webrtcbinelement. - Example pipeline (sender side):
gst-launch-1.0 ximagesrc ! videoconvert ! vp8enc deadline=1 ! rtpvp8pay ! webrtcbin stun-server=stun://stun.l.google.com:19302 - Signal exchange happens out-of-band (via signaling server).
- Browser receives stream with <200ms latency.
Pipeline 3: FFmpeg → RTP → WebRTC Server (Janus/GStreamer Gateway) → Browser
- FFmpeg sends RTP packets containing H264 video:
ffmpeg -f x11grab -s 1920x1080 -i :0.0 -c:v libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -f rtp rtp://webrtc-server:port - WebRTC server converts RTP to WebRTC streams with proper signaling.
- Browsers connect to server and receive low-latency streams.
Summary Comparison of Protocols for Low latency Desktop Streaming:
Protocol Latency Range Reliability Use Case Complexity UDP/MPEG-TS 200ms - 1s+ No packet recovery Simple LAN streaming Easy SRT 50ms - 200ms Packet recovery & security Reliable internet streaming Moderate RTP + RTSP 100ms - 300ms Some recovery IP camera and professional systems Moderate WebRTC 50ms - 150ms Advanced recovery + NAT traversal Interactive video, browsers, RTC apps High (signaling needed)
Recommendations
- If you want browser-based remote viewing with very low latency, investigate WebRTC with GStreamer or Janus Gateway.
- If you want a more straightforward but still reliable low-latency stream over WAN, use SRT with FFmpeg or GStreamer.
- For LAN or controlled environments, UDP + MPEGTS with VLC can work but latency usually is higher.
- Hybrid approach: Use SRT or WebRTC for ingest, then convert and distribute using lower latency protocols.
If you want, I can help you build a specific working example for either WebRTC-based desktop streaming or SRT-based FFmpeg push + VLC/SRT client. Just let me know!
- User
errors
dulu@dulu:~$ ffmpeg -f x11grab -s 1920x1080 -i :0.0
-vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M
-f mpegts "srt://192.168.100.19:1234?pkt_size=1316" ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 [x11grab @ 0x561b8d35c440] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, x11grab, from ':0.0': Duration: N/A, start: 1747172576.221340, bitrate: 1988667 kb/s Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1988667 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc [srt @ 0x561b8d36f500] Connection to srt://192.168.100.19:1234?pkt_size=1316 failed: Input/output error srt://192.168.100.19:1234?pkt_size=1316: Input/output errorerror dulu@dulu:~ ffmpeg -f x11grab -s 1920x1080 -i :0.0 \ -c:v libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts "srt://receiver_ip:port?pkt_size=1316" ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 [x11grab @ 0x564ca02c9440] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, x11grab, from ':0.0': Duration: N/A, start: 1747173101.126130, bitrate: 1988667 kb/s Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1988667 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc [srt @ 0x564ca02dc500] Port missing in uri srt://receiver_ip:port?pkt_size=1316: Invalid argument dulu@dulu:~
error dulu@dulu:~ ffmpeg -f x11grab -s 1920x1080 -i :0.0 -c:v libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -f rtp rtp://webrtc-server:port ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers built with gcc 11 (Ubuntu 11.2.0-19ubuntu1) configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc --enable-libsmbclient libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 [x11grab @ 0x5616c585d400] Stream #0: not enough frames to estimate rate; consider increasing probesize Input #0, x11grab, from ':0.0': Duration: N/A, start: 1747173370.507547, bitrate: 1988667 kb/s Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 1988667 kb/s, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc [udp @ 0x5616c5870b80] getaddrinfo(webrtc-server, 0): Name or service not known rtp://webrtc-server:port: Input/output error dulu@dulu:~
- Assistant
Thanks for providing the error messages! Let me explain what's going wrong and how to fix it:
1) Error:
[srt @ 0x561b8d36f500] Connection to srt://192.168.100.19:1234?pkt_size=1316 failed: Input/output errorCause:
FFmpeg is trying to connect to the SRT URL but fails. It means the receiver (server) isn’t listening on the given IP/port or it’s unreachable.
2) Error:
[srt @ 0x564ca02dc500] Port missing in uri srt://receiver_ip:port?pkt_size=1316: Invalid argumentCause:
You need to replace literallyreceiver_ipandportwith actual IP and port. This is likely from a copied example.
3) Error:
[udp @ 0x5616c5870b80] getaddrinfo(webrtc-server, 0): Name or service not known rtp://webrtc-server:port: Input/output errorCause:
webrtc-serveris not resolving to any host. You need to replacewebrtc-serverwith an actual IP or hostname of your WebRTC media server and replaceportwith a real port number.
How To Fix These Issues & Setup a Working Pipeline
Step 1: Set up SRT Receiver
FFmpeg won't magically create a receiver/listener for SRT—you need an SRT listener on the other side.
Example: On your receiver machine (IP:
192.168.100.19), you can start FFmpeg or any SRT-capable tool in listening mode:ffmpeg -i "srt://:1234" -c copy output.tsThis listens on port 1234 for incoming SRT streams.
Step 2: Send SRT stream from the sender
On your sender machine (where you run the desktop capture):
ffmpeg -f x11grab -s 1920x1080 -framerate 30 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts "srt://192.168.100.19:1234?pkt_size=1316"Replace
192.168.100.19with your actual receiver IP address.
Notes
- The SRT URL on the sender side is a client, connecting to the receiver's listening socket.
- On the receiver side
srt://:1234makes FFmpeg listen on port 1234 on all interfaces. - Make sure no firewall blocks UDP port 1234.
- Verify connectivity using tools like
srt-live-transmitornetcatto verify port is open.
Step 3: Using RTP streaming for WebRTC Gateway
You tried:
ffmpeg -f x11grab -s 1920x1080 -i :0.0 -c:v libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -f rtp rtp://webrtc-server:portFixes/recommendations:
- Replace
webrtc-serverwith your actual IP or hostname. - Replace
portwith the actual RTP receiving port number. - RTP requires setting up SDP and possibly separate audio streams, so just opening a UDP port is not enough.
- Many WebRTC media servers accept RTP encoded streams (e.g., Janus, Mediasoup), but you need to configure them correctly and feed them SDP info or use their API.
Without an actual WebRTC media server running and configured, this command will fail.
Step 4: Increasing Probesize Warning (optional)
You get the warning:
[x11grab @ 0x561b8d35c440] Stream #0: not enough frames to estimate rate; consider increasing probesizeIt is just informational and usually safe to ignore. But you can increase probesize for better detection:
ffmpeg -f x11grab -probesize 10M -s 1920x1080 ...
Summary: Minimal working example for SRT streaming desktop to another machine:
Receiver:
ffmpeg -i "srt://:1234" -c copy output.tsSender:
ffmpeg -f x11grab -s 1920x1080 -framerate 30 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts "srt://192.168.100.19:1234?pkt_size=1316"
Want to try simpler UDP streaming for testing?
Sender:
ffmpeg -f x11grab -s 1920x1080 -framerate 30 -i :0.0 \ -vcodec libx264 -preset ultrafast -tune zerolatency -g 15 -bf 0 -b:v 5M \ -f mpegts udp://192.168.100.19:1234Receiver (VLC):
udp://@:1234
Additional tips for WebRTC streaming
- You need a functioning WebRTC media server to receive RTP or raw WebRTC signaling.
- FFmpeg can send RTP to that server but can't handle signaling itself.
- Alternatively, use GStreamer with
webrtcbinand a signaling server (like Janus) for easier integration. - If you want I can help you set up a basic WebRTC streaming from your desktop via GStreamer and Janus.
If you want help setting up:
- SRT streaming across two computers
- WebRTC streaming with Janus or GStreamer
- Low-latency VLC streaming with UDP or RTP
just let me know!