How I embed videos in notes now

Every video on this site now lives next to the note that uses it, the same way images do. I drop a video into the note folder, reference it with one shortcode line, and pnpm ready handles the rest – transcoding, thumbnail/poster, upload, and the player.

  1. Drop the recording into the note folder, like content/raw/some-note/demo.mov
  2. Reference the mp4 name in the note, even when the dropped file is a .mov
{% video "./demo.mp4" %}
  1. Running pnpm ready transcodes the file to an optimized web-ready MP4 (H.264, yuv420p, faststart, crf 26, width capped at 1600px), extracts a poster frame from about 25% in as demo-poster.webp, records state in _data/cache/video-cache.json, and uploads the mp4 and poster to R2 under raw/some-note/ folder.

The above shortcode attaches the poster automatically, the player loads nothing until someone presses play, and nothing is fetched from a third party. I used to do this by hand and wrote down the ffmpeg commands earlier, but now it's all automatic.

Also, a few things worth knowing:

The first video I published this way is the demo in my whimsical Pi extension note, showing the rotating status phrases while Pi works.