#!/bin/sh # Publish a recording or screenshot to catcrafts.net and print the URL to put in # the fediverse post. # # usage: tools/publish-media.sh [-r] [-c CRF] ... # # -r, --raw upload the file unchanged (no transcode, no poster) # -c, --crf N AV1 quality, lower is better (default 32) # # WHY THIS EXISTS: the media used to be uploaded to a third-party file host and # then mirrored back at build time by tools/fetch-media.sh. That worked until a # 167 MB recording hit the mirror's size cap, and the deploy failed on a file we # had sitting on disk the whole time. Publishing to our own origin FIRST inverts # it — the URL in the post is already the URL the page wants, so there is nothing # to download, no size cap to clear, and no third party who can be slow, rate- # limit us, or delete the file that IS the post. # # The name is the content hash, matching what fetch-media.sh produces, which is # what makes Caddy's one-year immutable cache on /media honest: different bytes # can never appear under a name someone already has cached. # # TRANSCODE: phone recordings are enormous for what they show — the one that # started this was 78 s of a dark room at 17 Mbps, 167 MB, where denoising and # AV1 give the same picture in 15 MB. Dark handheld footage is mostly sensor # noise, which is expensive to encode and worth nothing, so hqdn3d earns its # place before the encoder rather than after it. # # ROTATION: phones record landscape and attach a display matrix instead of # rotating pixels. Transcoding bakes the rotation into the frames, so what every # downstream consumer measures is what the viewer actually sees — see the # rotation note in fetch-media.sh for what goes wrong when it does not. # # NOTE ON AV1: nothing here emits a fallback encoding, and the