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:
+24
-1
@@ -23,7 +23,7 @@ const managerVite = spawn('npx', ['vite', '--port', String(MPORT), '--strictPort
|
||||
const waiterVite = await startViteNative({ port: 5191, backendUrl: backend.url })
|
||||
const WAITER = 'http://localhost:5191'
|
||||
const browser = await chromium.launch(BROWSER_CHANNEL ? { channel: BROWSER_CHANNEL } : {})
|
||||
const r = reporter('media: Media page (batch upload, details), product photos (library + on the spot), waiter offline photos (5.2)')
|
||||
const r = reporter('media: Media page (batch upload, details), product photos (library + on the spot), waiter offline photos (5.2), video versions (5.4e)')
|
||||
const errors = []
|
||||
let failures = 0
|
||||
|
||||
@@ -110,6 +110,29 @@ try {
|
||||
await page.screenshot({ path: path.join(OUT, 'media-details.png') })
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// 5.4e: a phone video gets its still frame and a version every screen plays, in the background
|
||||
const ff = execFileSync(PYTHON, ['-c', 'import imageio_ffmpeg as i; print(i.get_ffmpeg_exe())']).toString().trim()
|
||||
const mov = path.join(OUT, 'IMG_0042.MOV')
|
||||
execFileSync(ff, ['-hide_banner', '-loglevel', 'error', '-y', '-f', 'lavfi', '-i', 'testsrc2=s=2560x1440:r=25:d=3', '-f', 'lavfi', '-i', 'sine=d=3',
|
||||
'-c:v', 'libx265', '-x265-params', 'log-level=error', '-tag:v', 'hvc1', '-c:a', 'aac', '-shortest', mov])
|
||||
await page.getByTestId('media-file-input').setInputFiles(mov)
|
||||
const vidItem = page.locator('[data-testid="media-item"][data-name="IMG_0042"]')
|
||||
r.check('5.4e: a phone video (HEVC .MOV, 2560 × 1440) goes into the library', await vidItem.waitFor({ timeout: 30_000 }).then(() => true).catch(() => false))
|
||||
r.check('5.4e: …and its still frame shows in the grid by itself once the server made it (no reload)',
|
||||
await vidItem.locator('img').waitFor({ timeout: 60_000 }).then(() => true).catch(() => false))
|
||||
await vidItem.click()
|
||||
const vstatus = page.getByTestId('media-video-status')
|
||||
r.check('5.4e: details: "a version for every screen is ready", with its size listed',
|
||||
await waitFor(async () => ((await vstatus.getAttribute('data-state').catch(() => null)) === 'ready' ? true : null), 60_000, 500)
|
||||
&& await page.getByTestId('media-sizes').locator('li').count() === 5)
|
||||
const vid = (await api('GET', '/api/media?kind=video', { token: boss })).items.find(i => i.name === 'IMG_0042')
|
||||
const play = await fetch(backend.url + vid.urls.play, { headers: { range: 'bytes=0-15' } })
|
||||
r.check('5.4e: the version plays as MP4 (seekable); the original MOV is kept as uploaded',
|
||||
play.status === 206 && play.headers.get('content-type') === 'video/mp4' && vid.content_type === 'video/quicktime'
|
||||
&& vid.bytes === statSync(mov).size, `${play.status} ${play.headers.get('content-type')}`)
|
||||
await page.screenshot({ path: path.join(OUT, 'media-video.png') })
|
||||
await page.keyboard.press('Escape')
|
||||
|
||||
// ── A product's photo from the library, another one uploaded on the spot ────
|
||||
const products = await api('GET', '/api/products/?sold_at=in_store,in_store_takeaway', { token: boss })
|
||||
const [p1, p2] = products.filter(p => !p.is_service_item && p.lifecycle_status === 'active')
|
||||
|
||||
+17
-1
@@ -100,6 +100,8 @@ try {
|
||||
// ── the TV ────────────────────────────────────────────────────────────────
|
||||
const tv = await (await browser.newContext({ viewport: { width: 1280, height: 720 } })).newPage()
|
||||
tv.on('pageerror', e => errors.push(e.message))
|
||||
const fetched = []
|
||||
tv.on('request', q => fetched.push(q.url()))
|
||||
await tv.goto(term.url)
|
||||
await shown(tv, 'pairing-code', 20_000)
|
||||
const code = await tv.getByTestId('pairing-code').getAttribute('data-code')
|
||||
@@ -123,6 +125,18 @@ try {
|
||||
r.check('the menu board lists the products with prices', await tv.getByTestId('signage-menu-item').count() > 0 && await tv.getByTestId('signage-menu-price').count() > 0)
|
||||
await tv.screenshot({ path: path.join(OUT, 'signage-menu.png') })
|
||||
|
||||
// ── 5.4e: the server makes the video's version for screens; the TV switches to it by itself ──
|
||||
const ready = await waitFor(async () => {
|
||||
const m = await api('GET', `/api/media/${video.id}`, { token: boss })
|
||||
return m.processing === 'done' || m.processing === 'failed' ? m : null
|
||||
}, 90_000, 1000)
|
||||
r.check('5.4e: the WebM video gets a still frame and a version every screen plays (H.264 MP4)', !!ready?.urls?.play && !!ready?.urls?.full,
|
||||
JSON.stringify(ready && { processing: ready.processing, urls: Object.keys(ready.urls) }))
|
||||
r.check('5.4e: …the TV is told and fetches that version without a reload',
|
||||
!!(await waitFor(async () => (fetched.some(u => u.endsWith(`${video.sha256}/play`)) ? true : null), 20_000, 300)))
|
||||
const poster = await waitFor(async () => ((await kindNow(tv)) === 'video' ? tv.getByTestId('signage-video').getAttribute('poster') : null), 30_000, 200)
|
||||
r.check('5.4e: …and plays it with its still frame behind it while it loads', !!poster, String(poster))
|
||||
|
||||
// ── a TV mounted sideways ─────────────────────────────────────────────────
|
||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { rotation: 90 } })
|
||||
r.check('turn the picture 90°: the frame turns', await waitFor(async () => (await tv.getByTestId('signage-frame').getAttribute('data-rotation')) === '90', 15_000, 300))
|
||||
@@ -280,7 +294,9 @@ try {
|
||||
// ── 5.6c: screens, schedules, the message of the day ─────────────────────
|
||||
await api('PUT', `/api/signage/screens/${dev.id}`, { token: boss, body: { playlist_id: pl.id } })
|
||||
await mgr.getByTestId('signage-tab-settings').click()
|
||||
await mgr.getByTestId('signage-weather').waitFor({ timeout: 10_000 }) // loaded: the message field holds the saved text
|
||||
await mgr.getByTestId('signage-weather').waitFor({ timeout: 10_000 })
|
||||
const savedMessage = (await api('GET', '/api/signage/message', { token: boss })).text || ''
|
||||
await waitFor(async () => ((await mgr.getByTestId('signage-message').inputValue()) === savedMessage ? true : null), 10_000, 200) // loaded
|
||||
await mgr.getByTestId('signage-message').fill('Kalimera from the manager')
|
||||
await mgr.getByTestId('signage-message-save').click()
|
||||
await sleep(700)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user