feat(hls): faster first-start — probe cache + tighter encoder presets (0.9.9)

Reduces first-segment latency on cache MISS so the player doesn't sit on
"preparando sesión". Three independent levers:

1. ProbeFile memoised by (path, mtime, size) for 30 min — second play of
   the same source skips ffprobe (1-3 s on 50+ GB MKVs).
2. HLS encoder presets biased for latency over quality:
   - libx264 default veryfast → superfast (~15-20% faster, marginal
     quality loss at 5-25 Mbps target bitrates).
   - NVENC: -preset p4 -tune hq → -preset p3 -tune ll. First-segment
     ~0.8 s on RTX-class GPUs (was ~1.5 s).
   - QSV: -preset medium → -preset veryfast (keeps look_ahead=0).
   - VideoToolbox: adds -realtime 1 (was unset). Bitrate args still
     drive rate control; -q:v dropped to avoid the silent conflict
     where ffmpeg ignored it under -b:v.
3. Per-session log surfaces encoder + accel + preset so "first-start
   was slow" complaints can be triaged from the journal alone.

Diagnostic helpers (DetectHWAccelDiagnostic + HWAccelDiagnostic) added
for future wiring into daemon startup / agent register; users today can
already inspect via `unarr probe-hwaccel`.

Web: AgentsTab profile page now shows the agent's chosen encoder
(amber if software libx264, green if HW) plus the transcode-resolution
cap. Hidden for pre-0.9.9 agents that haven't reported hwAccel.
This commit is contained in:
Deivid Soto 2026-05-27 10:09:42 +02:00
parent 7b78d0b778
commit 3b8d77b496
8 changed files with 593 additions and 17 deletions

View file

@ -5,6 +5,41 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [0.9.9] - 2026-05-27
### Added
- **per-session encoder log**: every HLS session start now logs
`encoder=… accel=… preset=…` so a "preparando sesión" complaint can
be triaged from the journal alone. Cache-HIT sessions keep the
existing simpler log (no ffmpeg involved).
- **probe cache**: `engine.ProbeFile` is memoised by `(path, mtime, size)`
for 30 minutes. A second play of the same file skips ffprobe
entirely — saves 1-3 s on first-segment latency for 50+ GB MKVs.
Cache key changes immediately on any file rewrite (mtime or size
delta).
- **agents tab transcoder row**: the web profile → agents tab now shows
each agent's selected encoder (`NVIDIA NVENC`, `Intel Quick Sync`,
`VA-API`, `macOS VideoToolbox`, or `Software (libx264)` in amber) plus
the comfortable transcode-resolution cap. Surfaces the same diagnostic
the daemon log carries.
### Changed
- **HLS encoder presets biased for first-start latency**:
- **libx264**: default `veryfast``superfast` (~15-20% faster encode;
marginal quality loss at 5-25 Mbps target bitrates). Users wanting
the previous quality can set `download.transcode.preset = "veryfast"`
in `config.toml`.
- **NVENC**: `-preset p4 -tune hq``-preset p3 -tune ll`. First-segment
encode drops from ~1.5 s to ~0.8 s on RTX-class GPUs.
- **QSV**: `-preset medium``-preset veryfast`. Keeps `-look_ahead 0`
for low-latency rate control.
- **VideoToolbox** (macOS): adds `-realtime 1 -q:v 50` (was unset). The
`realtime` flag steers VideoToolbox into the low-latency code path.
- Encoder + preset selection moved into `engine.ResolveEncoderProfile` so
the same logic drives both argv construction and the log line.
## [0.9.8] - 2026-05-27
### Fixed