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
@@ -6,9 +6,9 @@ import toast from 'react-hot-toast'
import { Trash2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useFormat, useTranslation } from '@xenia/i18n'
import { Button, Dialog, Field, Input, Spinner } from '@xenia/ui'
import { Button, Dialog, Field, Input, Spinner, cx } from '@xenia/ui'
import { deleteMedia, getMedia, renameMedia } from './mediaApi'
import { duration, fileSize, resolution, VARIANT_ORDER } from './mediaLogic'
import { duration, fileSize, preparing, resolution, VARIANT_ORDER, videoState } from './mediaLogic'
export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
const { t } = useTranslation('manager')
@@ -26,6 +26,16 @@ export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
.catch(err => { toast.error(errorMessage(err, t)); close.current() })
return () => { live = false }
}, [id, t])
// A video being prepared for screens (5.4e): follow it until it is done.
const changed = useRef(onChanged)
useEffect(() => { changed.current = onChanged })
const working = preparing([item])
useEffect(() => {
if (!working) return
const h = setInterval(() => { getMedia(id).then(m => { setItem(it => ({ ...it, ...m })); changed.current?.(m) }).catch(() => {}) }, 2000)
return () => clearInterval(h)
}, [working, id])
const state = videoState(item)
const save = async () => {
setBusy(true)
@@ -68,7 +78,7 @@ export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
<div className="grid gap-4" data-testid="media-details" data-id={item.id}>
<div className="rounded-card bg-surface-3 overflow-hidden flex items-center justify-center" style={{ maxHeight: '45vh' }}>
{item.kind === 'video'
? <video src={item.urls.original} controls preload="metadata" className="max-h-[45vh] max-w-full" />
? <video src={item.urls.play || item.urls.original} poster={item.urls.full} controls preload="metadata" className="max-h-[45vh] max-w-full" />
: <img src={item.urls.full} alt={item.name} className="max-h-[45vh] max-w-full object-contain" />}
</div>
@@ -90,6 +100,8 @@ export default function MediaDetails({ id, onClose, onChanged, onDeleted }) {
<section className="grid gap-1">
<h3 className="text-label font-semibold text-ink">{t('media.sizes')}</h3>
<p className="text-caption text-ink-3">{t(item.kind === 'video' ? 'media.sizesVideo' : 'media.sizesHint')}</p>
{state && <p className={cx('text-label font-medium', state === 'failed' ? 'text-danger-ink' : state === 'ready' || state === 'asIs' ? 'text-success-ink' : 'text-accent-ink')}
data-testid="media-video-status" data-state={state}>{t(`media.processing.${state}`, { progress: item.progress ?? 0 })}</p>}
<ul className="grid gap-1" data-testid="media-sizes">
{VARIANT_ORDER.filter(v => item.files?.[v]).map(v => (
<li key={v} className="flex gap-3 text-label">