Bound live-stream latency drift with periodic live-edge resync
Over hours the wall drifted ~15s behind real-time: the Pi decodes a hair slower than real-time, and since RTSP-over-TCP delivers every byte, that small deficit buffers up instead of being dropped — and a live stream can't be seeked back to the live edge. Add player.resync_seconds (0 = off): the daemon reconnects each stream to the live edge on that interval via mpv loadfile-replace over IPC, cycling one tile at a time so only a single tile ever blips. Reusing the running mpv process means no window teardown. At 600s this caps drift to a couple seconds. config.example.yaml ships it at 600; README documents the knob and the "also lighten decode load" caveat. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -331,6 +331,22 @@ func isStatusLine(s string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Reload reconnects mpv to its stream, snapping playback back to the live
|
||||
// edge. Live RTSP can't be seeked, so latency that accumulates when the Pi
|
||||
// runs a hair behind real-time is only cleared by reopening the stream. The
|
||||
// daemon calls this on a stagger so drift stays bounded without a visible
|
||||
// wall-wide blip. It reuses the running mpv process (no window teardown).
|
||||
func (p *Player) Reload() error {
|
||||
reply, err := p.Command("loadfile", p.URL, "replace")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if reply["error"] != "success" {
|
||||
return fmt.Errorf("mpv loadfile: %v", reply["error"])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sleep(ctx context.Context, d time.Duration) bool {
|
||||
t := time.NewTimer(d)
|
||||
defer t.Stop()
|
||||
|
||||
Reference in New Issue
Block a user