feat(media): video versions: still frame + a version every screen plays (platform-v2 5.4e)

- services/video.py: background worker (one video at a time, low priority) makes a still
  frame (thumb/card/full WebP) and, when needed, play.mp4 (H.264+AAC, <=1920 px, HDR
  tone-mapped, faststart); the original is kept. Media.processing/progress (migration 0031,
  existing videos queued). ffmpeg from the pinned imageio-ffmpeg wheel; none = as uploaded.
- MOV (video/quicktime) accepted; /api/media/file/<sha>/play served with ranges.
- Signage plays the version (poster = still frame) and tells the screens playing it when ready.
- Manager library: still frames in the grid, preparing progress, status in the details.
- Tests: test_video.py (8), backend 541 passed; e2e media/signage/stack new checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 02:10:22 +02:00
co-authored by Claude Opus 5.5
parent f8d0d29d8f
commit b5361e10ca
28 changed files with 756 additions and 39 deletions
+19
View File
@@ -8,6 +8,7 @@
// - the proxy still starts when the stack has no terminal container (older compose file)
// - a media upload bigger than nginx's 1 MB default gets through the proxy and the manager's
// nginx (step 5.1), and its sizes come back with year-long cache headers
// - a phone video gets its version for screens inside the backend image (ffmpeg, step 5.4e)
// node stack.mjs (builds the images: a few minutes the first time, cached after)
import { execFileSync, spawnSync } from 'node:child_process'
import { reporter } from './lib/env.mjs'
@@ -78,6 +79,24 @@ try {
card?.status === 200 && card.headers.get('content-type') === 'image/webp' && /immutable/.test(card.headers.get('cache-control') || ''),
`${card?.status} ${card?.headers.get('cache-control')}`)
// 5.4e: the backend image carries the video tool: a phone video gets its version for screens
const ff = execFileSync('python', ['-c', 'import imageio_ffmpeg as i; print(i.get_ffmpeg_exe())'], { encoding: 'utf8' }).trim()
const hevc = execFileSync(ff, ['-hide_banner', '-loglevel', 'error', '-f', 'lavfi', '-i', 'testsrc2=s=2560x1440:r=25:d=2', '-c:v', 'libx265',
'-x265-params', 'log-level=error', '-tag:v', 'hvc1', '-f', 'mov', '-movflags', 'frag_keyframe+empty_moov', 'pipe:1'], { maxBuffer: 64 << 20 })
const vf = new FormData()
vf.append('file', new Blob([hevc], { type: 'video/quicktime' }), 'IMG_0001.MOV')
const vid = await (await fetch(`${M}/api/media`, { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: vf })).json()
let done = null
for (let i = 0; i < 90 && vid?.id && !done; i++) {
const m = await (await fetch(`${M}/api/media/${vid.id}`, { headers: { Authorization: `Bearer ${token}` } })).json()
if (m.processing === 'done' || m.processing === 'failed' || m.processing == null) done = m
else await new Promise(res => setTimeout(res, 1000))
}
const play = done?.urls?.play ? await fetch(`http://127.0.0.1:19080${done.urls.play}`, { headers: { Range: 'bytes=0-15' } }) : null
r.check('media (5.4e): the backend image makes the version for screens of a phone video (ffmpeg inside), served seekable on :80',
vid?.processing === 'waiting' && done?.processing === 'done' && !!done.urls.thumb && play?.status === 206 && play.headers.get('content-type') === 'video/mp4',
`${vid?.processing} → ${done?.processing} ${play?.status}`)
// LAN vs not: the proxy joins a second network whose addresses aren't private
const proxy = stack.compose('ps', '-q', 'proxy').trim()
docker('network', 'create', '--subnet', '100.64.50.0/24', WAN)