videos.jhampton.io (private video site architecture)
videophpobject-storageencryptionapachejustinahampton
videos.jhampton.io is Justin's personal video site: series of phone clips (cat diaries, car clips, Snapchat exports), some public, some hidden, some encrypted. It is a small PHP app designed so the 1 GB server never touches the video bytes. Source ~/dev/justinahampton/videos/ (ops doc videos/README.md), deploy tools/deploy-videos.sh.
Architecture
- Bucket: private Linode bucket in Newark (
us-east-1.linodeobjects.com), chosen because that legacy endpoint supports CORS; the browser uploads to and plays from the bucket directly via pre-signed URLs. See Linode (Akamai) Object Storage. - Server: signs requests and holds metadata only. Catalog
/var/www/videos-data/videos.json, outside the deployed tree (A JSON file as the database (flat-file catalogs)). Config/var/www/html/videos/videos_conf.php(root:apache 640) holds bucket keys and password hashes. - Admin at
/admin/: upload with progress (16 MB multipart slices, three in flight), retitle, reorder, visibility, delete, orphan sweep, rotate, bulk actions, play in place. Guarded by a separate admin password.VIDEOS_API_TOKENletstools/videos-cli.phpwrite the catalog through the same API. - Passwords:
php tools/videos-cli.php hash-passwordthen paste the hash into the config. Nothing to restart; anyone already signed in stays signed in, since the hash is only checked at the login form. - Renditions: an optional HEVC alternate ahead of the H.264 file (Encoding phone clips for the web (HEVC remux, H.264 fallback)); a blur-up placeholder per card (Inline blur-up placeholders (LQIP): JPEG beats WebP across a page); rotation in CSS (Rotating video in CSS instead of re-encoding); in-place playback so sound works (Web video players: sound, mute, fullscreen and autoplay-next).
- Themes: CRT (default, floppy-disk cards over a phosphor photo), Daylight, Midnight, Terminal (CSS theme switching without a flash (and contrast over photos)).
URLs
- Each series has its own address (
/little-cat-diary) via one line in the Apache vhost:FallbackResource /series.php. It only fires when no real file matches, so/admin/,/watch.php,/assets/...,/sw.jscan never be shadowed by a slug, with no allowlist to maintain.series.phpis therefore also the 404 handler. - Pages have no
.phpin their addresses (/watch/<slug>,/login,/look,/admin/drops); the same fallback script routes them before any series lookup, the old file-name addresses 301, and those page names are reserved so no series can take them. Script-only endpoints such as/api/tv.phpkeep their names on purpose (Taking .php out of page addresses without breaking old links). /drop/<token>is a no-account upload page and/v/<token>a public watch-and-download page for a received file (Upload links for people without an account (getting a full-quality video from a friend)).- Slugs are matched loosely (any non-letter optional on the way in;
/littlecatdiary301s to the canonical). - Renames keep old links alive:
save-serieswithnewSlug409s on collision, moves the slug and appends the old one to the series'aliases; aliases 301 to the current slug. Storage keys are not rewritten. - An empty-looking series says which nothing: 404 signed in, 403 with a sign-in link when not; drafts 404 for everyone but the admin.
- Link previews: Open Graph tags on index, series and watch pages, with an unsigned
/poster/<slug>.jpgroute for public videos only (Open Graph link previews (SPAs, private posts, private-storage media)).
Private (encrypted) videos
Private videos are encrypted in the browser with a passphrase that exists only in Justin's head and browser; there is no reset and no recovery. Service-worker decryption plays them back. - Standing rule: back up a private video locally before it is encrypted and uploaded, through any channel (admin UI, CLI, script). The browser path writes the original to a chosen folder with the File System Access API (falling back to a plain download) and refuses to encrypt if the backup fails. "It is already on his disk because he picked it from there" does not count; the copy must be deliberate and reported. - Encryption is not a visibility setting: bulk visibility changes skip encrypted videos, and they never get a blur placeholder. - As of 2026-10 no encrypted video had been uploaded end to end, so the vault path is untested against real footage.
Native clients (TV app API)
/api/tv.php (2026-11) serves the Android TV app (Android TV / Google TV apps (Compose for TV, Media3, sideloading)): GET returns the catalog the
index would show this viewer (series, episodes with signed poster and source URLs, locked,
encrypted, rotate, expires); POST action=login returns the PHP session id as a token that
the app sends back as the site's session cookie (logout ends it). Locked videos carry no URLs;
encrypted ones are listed but unplayable, since only the web's service worker can decrypt them. A
failed login sleeps 2 s. It is a real file, so FallbackResource never shadows it. The same site
also hosts generated tutorial series (Generating narrated screencast tutorials from a script (PIL + Piper TTS + ffmpeg)).
Installing vhost changes
Diff the live vhost against the repo copy (videos/server/httpd-videos.justinahampton.conf) first, then scp, sudo cp, apachectl configtest, systemctl reload httpd. Never pipe a script to sudo -S on stdin; sudo eats it.
See also
- justinahampton.com and its subdomains
- Taking .php out of page addresses without breaking old links
- Upload links for people without an account (getting a full-quality video from a friend)
- Apache vhost gotchas (icons alias, manifests, SPA fallback, redirects)
Linked from
- A JSON file as the database (flat-file catalogs)
- Android TV / Google TV apps (Compose for TV, Media3, sideloading)
- Encoding phone clips for the web (HEVC remux, H.264 fallback)
- jhampton.io: one home domain, an index, and a wildcard certificate
- justinahampton.com and its subdomains
- Linode (Akamai) Object Storage
- Open Graph link previews (SPAs, private posts, private-storage media)
- Scripted video editing with FilmCraft (CLI/MCP), whisper transcripts, and a dashcam highlight reel
- Taking .php out of page addresses without breaking old links
- Upload links for people without an account (getting a full-quality video from a friend)
- Web video players: sound, mute, fullscreen and autoplay-next