Video pipeline
Status: built; tested end to end with small synthetic videos generated by ffmpeg inside the tests. Never run on a real lecture recording.
Path of a video
browser ──4 MiB pieces + SHA-256 each──▶ /admin/api/uploads/… uploads/<id>/000000… (never served)
complete: assemble, re-hash, magic bytes ─────────────────▶ masters/<sha256>.<ext> (kept untouched, never served)
job « transcode » in the SQLite queue ◀── worker process (scripts/worker.ts, PM2 « atlas-worker »)
ffprobe validation → ffmpeg ladder → poster, thumbnails → work/job-<id>-<attempt>/
atomic move ───────────────────────────────────────────▶ media/<session>/<capsule>/<encode>/
captions / transcript / chapters (validated) ─────────────────────▶ media/<session>/<capsule>/<name>.<hash>.<ext>Layout of one capsule (what the player and the routes expect)
ATLAS_DATA_DIR/media/<sessionId>/<capsuleId>/
r<encode-id>/master.m3u8 one EXT-X-STREAM-INF per rendition: measured peak BANDWIDTH, RESOLUTION, CODECS read from the segments
r<encode-id>/v<height>/index.m3u8, seg_00000.ts … H.264 + AAC, 4 s segments, key frames forced every 4 s (aligned across renditions)
r<encode-id>/fallback.mp4 progressive, faststart, best rendition ≤ 720 lines
r<encode-id>/poster.jpg, thumbs/t_001.jpg …
captions.<lang>.<hash>.vtt normalised WebVTT, one per language
transcript.<hash>.json { lang, segments: [{ start, end, text }] }
chapters.<hash>.json [{ start, title }]It is the layout of scripts/make-test-capsule.ts with one addition: every encode has its own directory and every sidecar file a name derived from its content. Files are never rewritten in place, so a publication keeps naming exactly the bytes it was made with. /media/[...path] serves a file only if a live publication names it (mediaAllowed): a draft, a newer encode or a master has no public address at all.
Encoding
- Ladder:
ATLAS_LADDER(JSON) or the default 360p/800 kb/s, 720p/2800, 1080p/5000 (audio 96/128/160 kb/s AAC stereo 48 kHz). Never upscaled: only rungs at or below the source height; a source between two rungs (e.g. 480p) also gets a rung at its own height; a source below the first rung is delivered at its own size. Tested: 180p → [180], 360p → [360], 480p → [360, 480]. libx264, presetATLAS_X264_PRESET(defaultmedium), CRF 21 capped by-maxrate,mainprofile below 720p andhighfrom 720p,yuv420p. A silent source is encoded without an audio track (tested).- Limits:
ATLAS_MAX_VIDEO_MIN(240),ATLAS_JOB_TIMEOUT_MIN(240),ATLAS_WORKER_CONCURRENCY(1; max 4). ffmpeg/ffprobe run without a shell and are killed by PID on cancel or timeout.
Queue and worker
Table jobs; states queued → running → succeeded | failed | cancelled. Three attempts with back-off (15 s, 1 min, 4 min); errors that retrying cannot fix (not a video, ffmpeg missing, master gone) fail at once with a French message shown on the capsule. The worker writes a heartbeat every loop; jobs of a worker that died are put back in the queue after 90 s; SIGTERM gives the running job back without consuming an attempt. Stale uploads are swept after two days.
ffmpeg is checked at run time (ffmpeg -version, -encoders for libx264 and aac). If it is missing: the dashboard shows a red notice, /api/health/details and pnpm studio health report ffmpeg.ok: false with the reason, and encode jobs fail immediately with « ffmpeg est introuvable… » instead of hanging. The rest of the studio keeps working.
Storage and bandwidth — orders of magnitude, not measured on real lectures
With the default ladder's caps (a ceiling; CRF usually lands lower for slides and talking heads): 360p + 720p + 1080p + MP4 fallback ≈ 0.8 + 2.8 + 5.0 + 2.8 Mb/s ≈ 11.4 Mb/s → ≈ 5 GB per hour of video at most, plus the master (a 4K master is commonly 20–45 GB per hour). 24 sessions × ~1 h ≈ 120 GB of renditions at the ceiling, plus masters. A learner watching 720p uses ≈ 1.3 GB per hour at the cap. Measure the first real recording (du -sh media/<session>/<capsule>) and set ATLAS_QUOTA_GB; these figures are estimates from bitrates, nothing else. Old encodes are not deleted automatically (a publication may name them): no garbage collector exists yet.
Not built / not verified
Waveforms; automatic poster choice (the poster is the frame at 3 s or 10 %); slide synchronisation; GPU or VideoToolbox encoding; purge of unreferenced encodes; real lecture-length sources; 4K sources; HDR, variable-frame-rate and rotated phone footage (rotation is read from metadata but untested); playback of the produced streams on a real iPhone/iPad (headless Chromium only for studio-produced media).