By: Michael Lynch <git@mtlynch.io>
Make video transcoding durable and tune the encoder Rework background video transcoding so it survives restarts and fails visibly, and tune ffmpeg for the resolutions we actually serve. - Treat media_items 'processing' rows as a durable queue: the worker drains the DB (ReadNextProcessingVideo) and resumes any video left processing by a crash or restart. The HTTP handler no longer blocks on a full in-memory channel. - Retain original video uploads under --originals-dir (defaults beside the DB) as both the worker's transcode source and the record DESIGN requires, instead of a deleted temp file. - Add a 'failed' media status so a deterministic transcode error shows the uploader a re-upload notice rather than a perpetual "processing" one. Crash -> still processing (retried); error -> failed. - Shut down gracefully: cancel the in-flight ffmpeg on SIGTERM via exec.CommandContext and an http.Server/Server.Shutdown handshake; the cancelled item stays processing and resumes next start. - Cap served video to a 2560px box (no upscale), add VP9 speed flags, and seek past the blank opening frame for thumbnails. Missing ffmpeg or ffprobe surfaces at conversion time, not startup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>