From 2459274a19f95a94499fc66b65b54741782411c9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 2 Sep 2025 12:37:28 +1200 Subject: [PATCH] Optimize streaming latency: remove -re flag, add keyframe settings, reduce HLS segments, faster ICE timeout --- squashkiwi-streaming/config/mediamtx.yml | 4 ++-- squashkiwi-streaming/config/transcoder/transcoder.sh | 5 ++++- squashkiwi-streaming/config/web/webrtc.html | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/squashkiwi-streaming/config/mediamtx.yml b/squashkiwi-streaming/config/mediamtx.yml index 683d7dc..645619c 100644 --- a/squashkiwi-streaming/config/mediamtx.yml +++ b/squashkiwi-streaming/config/mediamtx.yml @@ -22,8 +22,8 @@ rtspTransports: [tcp, udp] hls: yes hlsAddress: :8888 hlsAllowOrigin: '*' -hlsSegmentCount: 10 -hlsSegmentDuration: 2s +hlsSegmentCount: 3 +hlsSegmentDuration: 1s hlsPartDuration: 200ms hlsAlwaysRemux: yes diff --git a/squashkiwi-streaming/config/transcoder/transcoder.sh b/squashkiwi-streaming/config/transcoder/transcoder.sh index 8674f45..5da5433 100644 --- a/squashkiwi-streaming/config/transcoder/transcoder.sh +++ b/squashkiwi-streaming/config/transcoder/transcoder.sh @@ -9,7 +9,6 @@ fi # Start ffmpeg with drawtext filter for score overlay exec ffmpeg \ - -re \ -rtsp_transport tcp \ -i rtsp://localhost:8554/court \ -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:\ @@ -25,7 +24,11 @@ y=10" \ -c:v libx264 \ -preset ultrafast \ -tune zerolatency \ + -g 30 \ + -keyint_min 30 \ -b:v 2M \ + -maxrate 2M \ + -bufsize 1M \ -f rtsp \ -rtsp_transport tcp \ rtsp://localhost:8554/court_h264 \ No newline at end of file diff --git a/squashkiwi-streaming/config/web/webrtc.html b/squashkiwi-streaming/config/web/webrtc.html index 4f8d88e..a67096d 100644 --- a/squashkiwi-streaming/config/web/webrtc.html +++ b/squashkiwi-streaming/config/web/webrtc.html @@ -230,8 +230,8 @@ resolve(); } }; - // Timeout after 2 seconds - setTimeout(resolve, 2000); + // Timeout after 500ms for faster connection + setTimeout(resolve, 500); } });