fix(stream): functional libplacebo probe + benchmark hardening
Review (critico) caught a regression: the prod agent image ships a BtbN GPL ffmpeg with libplacebo COMPILED IN but no Vulkan runtime (debian-slim, no libvulkan1/mesa-vulkan-drivers/nvidia ICD). The presence probe (ffmpeg -filters) would flip HasLibplacebo on, the filter's Vulkan device creation would fail at runtime, and HDR sources that previously tonemapped via zscale would break. - FFmpegSupportsLibplacebo now RUNS the filter on one synthetic frame and requires a clean exit (forces Vulkan device init + filtergraph negotiation), so it is honest about THIS host: works on Vulkan-capable hosts, falls back to zscale where Vulkan is absent. Logs the real ffmpeg error on failure. - Warm the libplacebo (Vulkan init ~1.7s) + zscale caches in a background goroutine at startup so the first stream session doesn't pay the probe and risk its setup timeout. - Benchmark: margin 1.5x -> 2.0x (the probe measures encode only; real decode of HEVC/10-bit + busier content needs more headroom), per-probe timeout 12s -> 6s + overall 45s -> 20s (it blocks registration on software hosts), and a 'no rung measured' case (missing lavfi/wedged ffmpeg) now keeps the 1080 default instead of flooring at 480 — an infra failure isn't a slow host. Verified e2e on the fixed binary: LOTR Two Towers (HEVC 3840x1608 10-bit HDR10/PQ, 12GB) on desktop-Chrome caps -> hls, ffmpeg runs h264_nvenc with -vf ...,libplacebo=...:format=yuv420p:tonemapping=bt.2390 (zscale chain replaced), 45 fMP4 segments, ffprobe confirms output h264 yuv420p bt709 (tonemapped from bt2020/smpte2084), no ffmpeg errors.
This commit is contained in:
parent
ef3b190e0b
commit
cfaedb7f3b
4 changed files with 102 additions and 21 deletions
|
|
@ -2,6 +2,7 @@ package engine
|
|||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -112,6 +113,22 @@ func TestTonemap_VAAPIInsertsBeforeHwupload(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFFmpegSupportsLibplacebo_FunctionalProbe(t *testing.T) {
|
||||
if FFmpegSupportsLibplacebo("") {
|
||||
t.Error("empty path must be false")
|
||||
}
|
||||
// A bogus path can't run → false (no panic, no hang).
|
||||
if FFmpegSupportsLibplacebo("/nonexistent/ffmpeg") {
|
||||
t.Error("nonexistent ffmpeg must be false")
|
||||
}
|
||||
// With a real ffmpeg the result is environment-dependent (true only when a
|
||||
// Vulkan runtime is present), so we only assert the probe completes and
|
||||
// returns a bool — its whole purpose is to be honest about THIS host.
|
||||
if _, err := exec.LookPath("ffmpeg"); err == nil {
|
||||
_ = FFmpegSupportsLibplacebo("ffmpeg") // must not hang or panic
|
||||
}
|
||||
}
|
||||
|
||||
func TestFFmpegSupportsZscale_Stub(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue