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:
@@ -37,6 +37,7 @@ from core.errors import XeniaError
|
||||
from database import get_db
|
||||
from models.signage import SignagePlaylist, SignageSchedule, SignageSlide
|
||||
from services import media as media_store
|
||||
from services import video as video_store
|
||||
from services.ws_bus import broadcast_sync
|
||||
|
||||
router = APIRouter()
|
||||
@@ -406,8 +407,12 @@ def _media_map(db, ids) -> dict:
|
||||
out = {}
|
||||
for m in (db.query(Media).filter(Media.id.in_(ids)).all() if ids else []):
|
||||
urls = media_store.urls(m)
|
||||
video = m.kind == "video"
|
||||
out[str(m.id)] = {"id": m.id, "kind": m.kind, "name": m.name, "width": m.width, "height": m.height,
|
||||
"duration_ms": m.duration_ms, "url": urls.get("full") or urls["original"],
|
||||
"duration_ms": m.duration_ms,
|
||||
# a video plays its version made for screens once there is one (5.4e)
|
||||
"url": media_store.video_src(m) if video else urls.get("full") or urls["original"],
|
||||
"poster": urls.get("full") if video else None,
|
||||
"thumb": urls.get("thumb"), "builtin": bool(m.builtin)}
|
||||
return out
|
||||
|
||||
@@ -428,6 +433,17 @@ def _uses(db, media_id: int) -> list:
|
||||
media_store.register_usage("signage_slide", _uses)
|
||||
|
||||
|
||||
def _video_done(db, media_id: int) -> None:
|
||||
"""A video's playable version is ready (services/video.py): the screens playing it switch to it."""
|
||||
playlists = {s.playlist_id for s in db.query(SignageSlide).filter(SignageSlide.kind == "video")
|
||||
if media_id in media_ids(s.content or {})}
|
||||
if playlists:
|
||||
_tell([d for pid in playlists for d in _screens_playing(db, pid)])
|
||||
|
||||
|
||||
video_store.on_done(_video_done)
|
||||
|
||||
|
||||
def tell_all_screens(db) -> None:
|
||||
"""Something every screen may show changed (the message of the day, the weather)."""
|
||||
_tell([d.id for d in _screens(db)])
|
||||
|
||||
Reference in New Issue
Block a user