improved livedelay

This commit is contained in:
2026-04-10 02:56:04 -03:00
parent d83576a3ba
commit e2ca18d120
3 changed files with 10 additions and 3 deletions

View File

@@ -103,8 +103,12 @@ class Player:
def load_live(self, url):
"""Load a live stream URL with low-latency options."""
self._player["cache"] = "no"
self._player["demuxer-max-bytes"] = "512KiB"
self._player["audio-buffer"] = 0.2
self._player["demuxer-max-bytes"] = "256KiB"
self._player["demuxer-readahead-secs"] = 0
self._player["audio-buffer"] = 0.1
self._player["untimed"] = True
self._player["video-latency-hacks"] = True
self._player["interpolation"] = False
log.info("mpv load_live: %s", url)
self._player.loadfile(str(url), mode="replace")

View File

@@ -158,7 +158,7 @@ fn spawn_ffmpeg(cfg: &SubprocessConfig) -> Result<Child> {
"-init_hw_device".into(), format!("drm=drm:{}", cfg.device),
"-init_hw_device".into(), "vaapi=va@drm".into(),
// Video input (kmsgrab)
"-thread_queue_size".into(), "64".into(),
"-thread_queue_size".into(), "512".into(),
"-device".into(), cfg.device.clone(),
"-f".into(), "kmsgrab".into(),
"-framerate".into(), cfg.fps.to_string(),

View File

@@ -63,6 +63,8 @@ impl Session {
let mut child = Command::new("ffmpeg")
.args([
"-fflags", "nobuffer",
"-flags", "low_delay",
"-f", "h264",
"-framerate", &fps.to_string(),
"-i", "pipe:0",
@@ -75,6 +77,7 @@ impl Session {
// UDP relay for live display
"-c:v", "copy",
"-f", "mpegts",
"-flush_packets", "1",
RELAY_URL,
"-hide_banner", "-loglevel", "warning",
])