6.6 KiB
Easy Stream
Easy Stream is a browser-first streaming layer for a read-only Matroska archive. It keeps the original MKV files untouched, remuxes compatible H.264/AAC sources to CMAF/fMP4 HLS only when requested, and bounds those generated files with a 2 TB LRU cache. Incompatible SDR sources can be prepared once as a durable, same-resolution H.264/AAC representation; HDR is held for review in v1.
The first version targets Chrome, Firefox, and modern MSE-capable Android TV browsers. The UI is guest-first, Persian/RTL by default, remote-control friendly, and stores viewer preferences and resume progress only in IndexedDB.
Repository layout
apps/web: Vue/Vite catalog, TV navigation, player, local progress, and admin UI.apps/api: Fastify catalog, playback sessions, signed media authorization, admin, and TMDB metadata endpoints.apps/worker: archive scanner, BullMQ worker, JIT packager, offline compatibility encoder, and cache maintenance.packages/contracts: closed TypeBox API, queue, snapshot, and registry contracts.packages/media: FFmpeg, subtitle, font, HLS validation, path-safety, and LRU primitives.packages/database: Drizzle schema, migrations, catalog synchronization, and job lifecycle helpers.infra: production Node/FFmpeg images and the same-origin Nginx gateway.
See architecture.md for the media decisions and operations.md for deployment gates.
What happens to a movie
| Source | v1 behavior | Storage |
|---|---|---|
| Browser-compatible H.264/AAC SDR | Stream-copy to progressive fMP4 HLS on first play | Bounded, disposable cache |
| H.264 SDR with incompatible audio | Copy video and encode audio to AAC | Bounded, disposable cache |
| Other SDR video | One offline H.264/AAC encode at the source resolution | Durable derived disk |
| HDR, Dolby Vision, invalid, or incomplete media | Not published | Original only |
ASS subtitles are preserved for JASSUB/libass rendering, with WebVTT fallback. Embedded fonts are validated, content-addressed, and exposed only inside the signed generation path.
Local verification
Requirements: Node.js 24 LTS (22 is supported for development), pnpm 11 through Corepack, and FFmpeg/ffprobe 8.x.
cp .env.example .env
corepack pnpm install
corepack pnpm typecheck
corepack pnpm test
corepack pnpm build
corepack pnpm scan:samples
scan:samples writes a public data/metadata/catalog.json and a private data/metadata/inventory.json. Source paths and probe details never enter the public snapshot.
To package one scanned media item with the locally installed FFmpeg, copy its UUID from inventory.json and run:
node apps/worker/dist/cli.js package \
--root ./movies \
--cache ./data/cache \
--inventory ./data/metadata/inventory.json \
--registry ./data/metadata/package-registry.json \
--media-item MEDIA_ITEM_UUID
The original file is opened read-only. Generated media is written under data/cache/generations/<generation-id>.
Ubuntu / Docker Compose
On a fresh Ubuntu server, clone this repository and run the interactive bootstrap. It asks for the real HTTPS origin, storage paths, cache size, administrator account, passwords, signing secrets, concurrency, playback lifetime, and optional licensed TMDB access. Secret input is hidden; blank infrastructure secrets are generated securely.
chmod +x scripts/setup-ubuntu.sh
bash scripts/setup-ubuntu.sh
The script installs Docker Engine and the Compose plugin from Docker's official apt repository, asks which host address may expose port 8080 (loopback by default), creates the writable host directories for UID/GID 1000, backs up an existing .env, writes the replacement with mode 0600, validates the rendered Compose configuration, and asks before building or starting containers. Use --no-start to configure without launching, or --skip-docker-install when a supported Docker installation already exists.
If you decline the offered Caddy step, the main bootstrap leaves DNS, TLS termination, and inbound firewall configuration untouched. CDN edge authorization, archive mounts, and backups remain separate production gates in either case.
To publish an already-running installation, use the separate domain bootstrap. It installs Caddy, configures automatic HTTPS, and proxies the public hostname to the loopback-only gateway:
bash scripts/setup-domain.sh
Manual alternative
- Copy
.env.exampleto.envand replace every bootstrap password and signing secret. KeepPLAYBACK_SIGNING_SECRETandMEDIA_AUTH_SHARED_SECRETdifferent. - Set absolute
ARCHIVE_ROOT,CACHE_ROOT,DERIVED_ROOT, andMETADATA_ROOTpaths. The archive is mounted read-only. - Make the three writable directories available to UID/GID
1000:1000, used by the unprivileged worker image. - Set
WEB_ORIGIN,PUBLIC_ORIGIN, andMEDIA_PUBLIC_BASE_URLto the same public HTTPS origin. Put port 8080 behind the CDN/TLS edge and restrict direct origin access. - Start the stack:
docker compose build
docker compose up -d
docker compose ps
Compose waits for PostgreSQL, applies migrations once, then starts the API, worker, and gateway. On a new installation, open /admin, sign in with the bootstrap administrator, and start the first archive scan. The worker writes the snapshots and transactionally imports public catalog rows into PostgreSQL.
Cold playback is automatic. For a media item classified VIDEO_TRANSCODE, run the deliberate offline preparation command before publishing it:
docker compose exec worker node apps/worker/dist/cli.js prepare \
--root /archive \
--derived /data/derived \
--inventory /data/metadata/inventory.json \
--registry /data/metadata/package-registry.json \
--media-item MEDIA_ITEM_UUID
Important v1 boundaries
- There is one representation, not an adaptive-bitrate ladder. A slow connection cannot switch to a lower quality.
- Compatible media still occupies temporary HLS cache space; “no duplication” means no permanent HLS copy for every title.
- Durable compatibility encoding is intentionally operator-controlled and CPU-limited to one job at a time.
- TMDB stays disabled until both an API token and explicit commercial-license confirmation are configured.
- The gateway deliberately marks media responses
private. Do not override that at a CDN until the CDN validates a signed playback grant before every cache lookup; merely forwarding the cookie on cache misses is not authorization. - Physical Android TV, CDN, Redis/PostgreSQL failure recovery, incompatible-SDR encoding, and the full 100 TB census remain production acceptance gates.