Repository navigation
Add project page + hero video playbook and ffmpeg scripts - #1470
jonfroehlich wants to merge 5 commits into
Conversation
docs/PROJECT_VIDEO_PLAYBOOK.md records how we publish a project page with a hero (banner) video and an official YouTube video: no text in hero media, one small (<= 2.5 MB) 2:1 loop per project with a poster and alt text, official video on the lab channel with the logo prologue, and the /admin steps. scripts/video/make_hero.sh renders the loop, poster, and gallery thumbnail; scripts/video/add_prologue.sh prepends the lab logo animation for YouTube uploads. CLAUDE.md points to the playbook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
jonfroehlich
left a comment
There was a problem hiding this comment.
Reviewed at head a9be7aedf52bf44ac8b7e6359dc7eea0f16d9f0d (review round 1, comment only).
Summary: no blocking findings. On Linux with a 16:9 source, both scripts do what the playbook says. There are 8 should-fix items (4 in the scripts, 4 in the playbook text) and a few nits.
How I tested: ran both scripts from a detached checkout of this head against synthetic ffmpeg sources (testsrc2, sine, mandelbrot+noise) with ffmpeg n8.0.1 (static build) on Linux, including paths with spaces, a relative output directory, and invocation from another directory. Rendering claims were checked in headless Chromium with a static page that uses the base.html carousel markup and loads the repo's CSS in template order. Nothing was run on macOS, Firefox or Safari.
What checked out
make_hero.shon 1920x1080/30 fps, 1280x720/23.976 fps and a variable-frame-rate source (r_frame_rate60, average 42): output is 1600x800, H.264 High, level 4.0,yuv420p, 30 fps, SAR 1:1, a single video stream (no audio),moovbeforemdat, 1.7 to 1.9 MB at CRF 27.- The loop is seamless. On an 11 s cut (10 s loop), the last frame matches source frame 29 and the first frame matches source frame 30 (PSNR 31 to 32 dB against the source, versus 18 dB for the adjacent frame). The seam difference (18.4 dB on this fast-changing test pattern) is the same as any other pair of consecutive frames (17.9 to 19.3 dB).
- Poster is 1600x500 and equals the centre band (y 150 to 650) of frame 0. Thumbnail is 1000x600, which matches
PROJECT_THUMBNAIL_SIZE(500x300, 5:3). speed,yposandextra_vfwork as described (a 6 s cut at 0.5 gives an 11 s loop).add_prologue.sh: output is 1920x1080 H.264 + AAC 48 kHz stereo; frame rate follows the source (30, 24000/1001, 60); audio is silent for exactly the logo's 5.000 s and the source audio starts there; a source with no audio gets a silent track; a missingLOGOgives the intended error and exit 1.- Geometry: at 360 px wide the project-page hero shows the centre 576x800 of the master, and at 2560 px it shows 1600x312, so the "576x312" figure is right for the project-page video (but see S8).
- Admin steps match the code:
BannerInlineis on the project form, a blank banner title falls back to the project name, staff can preview a hidden project,Banner.croppingis 1600x500. - Both scripts are committed as mode 100755.
Should-fix: scripts
S1. The size cap is not enforced, and three different numbers are in play. The playbook says target 2.5 MB and hard cap 4 MB, the script header and PR body say "<= ~2.7 MB", and the loop tests 2,700,000 bytes. When CRF 31 is still over, the script keeps the file and exits 0 with no warning. Reproduced: a busy 12 s cut at speed 0.5 (the playbook recommends 0.5 to 0.85) printed crf=31 3040KB 23.000000s, exit 0, 3,113,763 bytes. Nothing checks 4 MB either. Suggest one number, and a non-zero exit (or at least a loud warning) when the last CRF is still over it.
S2. stat -c %s is GNU-only. Not run on macOS; simulated with a stat stand-in that rejects -c the way BSD stat does. Result: the size test errors on every pass ([: : integer expression expected), so the loop always falls through to CRF 31 (the lowest quality) regardless of size, the final printf then fails on $(( /1024 )), and the script exits 1 after writing the files. add_prologue.sh line 32 has the same call; with the same stand-in it exits 1 after a successful encode. wc -c < file is portable.
S3. Sources wider than 2:1 fail. crop=iw:iw/2:... needs ih >= iw/2. Reproduced with a 2560x1080 source: Invalid too big or non positive size for width '2560' or height '1280', exit 234, and a 0-byte <slug>-inter.mp4 left behind. The same expression rejects 1920x900 (checked on the crop filter alone), which is what the playbook's own "pre-crop the toolbars" advice can produce. This expression handled 2560x1080, 1920x1080 and 1278x720 in my test: crop='min(iw,2*ih)':'min(ih,iw/2)':(iw-ow)/2:(ih-oh)*$y.
S4. add_prologue.sh takes r_frame_rate, which is not the real frame rate for some variable-frame-rate files. Reproduced on a synthetic 30 fps MP4 with millisecond-jittered timestamps (ffprobe: r_frame_rate=1000/1, avg_frame_rate=1000/33): the output was 1000 fps, 10,938 frames for 10.9 s, H.264 level 6.1. I do not know how common this is in the lab's real sources; screen recorders and phones are the usual producers of such files. avg_frame_rate, or a cap at 60, avoids it.
S5. The poster and thumbnail JPEGs come out with shifted colours for BT.709 sources. The stills are cut from the BT.709 hero and written as JPEG with only a range conversion, not a matrix conversion, and browsers decode JPEG as BT.601. Reproduced with a BT.709-tagged source in headless Chromium at 1600 px, same pixel in poster and video: red is e70001 in the poster versus fd0002 in the video; yellow is f9ff07 versus fcfd0a. So the colours visibly change when the video replaces the poster. Adding scale=in_color_matrix=bt709:out_color_matrix=bt601:out_range=pc,format=yuvj420p to the poster command brought red to fa0100 (poster-versus-video screenshot PSNR 27.6 dB to 31.9 dB). Hard-coding BT.709 as the input matrix also matches what Chromium assumed for the untagged 1600x800 hero in my other test.
Should-fix: playbook
S6. The contact-sheet command silently shows only the first 3 min 20 s. fps=1/5 with tile=8x5 and -frames:v 1 is 40 tiles, which is 200 s. Reproduced on a 400 s source: one 2560x900 sheet whose last tile is stamped 00:03:15, exit 0, the second half of the video never shown. Drop -frames:v 1 and write sheet_%02d.jpg, or scale the interval to the duration.
S7. Rule 7 says member bios filter hidden project names "as of #1469", but #1469 is an open, unmerged PR. At this head website/utils/bio_utils.py still builds the sentence from person.get_projects with no visibility filter. Either merge #1469 first or reword until it lands.
S8. "Keep the subject in the center ~576x312 px of the master (visible on every screen)" does not hold in two cases. Both rendered in headless Chromium:
- Poster on phones. The poster is the 1600x500 crop, shown in the same
object-fit: coverbox. At 390 px wide the poster shows the centre 390 px of the master at 1:1, while the video shows the centre 624 px scaled by 0.625. So the poster is 1.6x tighter than the video (about 1.11x at 1440 px). Rule 3 names the poster as what reduced-motion visitors see, so on a 360 px phone they see only the centre 360 px. - Landing page.
index.cssloads afterbase.cssand redefines.banner-video(width: auto,min-width: 100%, centred with a transform). Measured video box at a 360 px viewport: 1600 px wide, offset -620 px, so only the centre 360 px of the master is visible, versus 576 px on a project page. This applies to any banner that also haslanding_pagechecked.
A safe area of about 360x312 covers both; otherwise the paragraph should say it describes the project-page video only.
Nits
- N1. The rendering paragraph cites
base.html, but the 500 px height andobject-fit: coverlive inwebsite/static/website/css/base.css(.carousel ... { height: 500px },.banner-video). - N2.
Banner.videohelp text still says "Ideally, video should be 10MB or less", andvalidate_video_uploadaccepts.movwhile the template hardcodestype="video/mp4". Both contradict rule 4 until #1468 lands; worth a sentence in the playbook so editors are not confused by the admin form. - N3. Missing arguments give
$1: unbound variablewith no usage line, and-hdoes the same.make_hero.shalso needspython3,realpathand GNUstat, which the "Install tools once" line does not mention. - N4. The loop is 1 s shorter than the cut (an 11 s cut gives a 10 s loop); the header does not say so. A cut under 2 s after
speedis not rejected: 1.5 s in gave a 1.0 s file and exit 0 (I did not inspect its content). - N5. A failed run leaves
<slug>-inter.mp4in the output directory (seen in S3). Atrap ... EXITwould clean up. - N6. A source whose width is not exactly twice the cropped height keeps a non-square SAR: 1278x720 in gave 1600x800 with SAR 639:638.
setsar=1after the scale fixes it (checked together with the S3 expression). - N7. Derived from code, not tested on a server: the gallery thumbnail is uploaded with its own filename to
projects/images/(no random suffix, unlike banners), so<slug>-thumb.jpgfor a hidden project is fetchable under/media/by anyone who guesses the name. Rule 7 could say to hold media uploads for unpublished work, or to use a non-descriptive filename. - N8. Untested reasoning:
extra_vfruns beforesetpts, sominterpolate=fps=30combined withspeedbelow 1 would interpolate first and then duplicate frames when slowed.
Not checked
Real footage of any kind (all sources were synthetic), HDR or 10-bit sources, macOS, Firefox and Safari, the actual lab logo animation, and YouTube's handling of the prologue output.
🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2
make_hero.sh: - One size policy: 2.5 MB target (warn), 4 MB hard cap (exit 3). - Portable: wc -c instead of GNU stat, awk instead of python3, no realpath. - Crop the largest 2:1 rectangle, so sources wider than 2:1 work; setsar=1. - Convert BT.709 to BT.601 full range for the poster/thumbnail JPEGs so their colours match the video. - extra_vf runs after setpts, so minterpolate sees the slowed timeline. - STILL_AT rotates the seamless loop so the payoff moment is frame 0 (poster and thumbnail), keeping it seamless. - Usage/-h, argument checks, minimum cut length, intermediates removed on any exit. add_prologue.sh: - Use r_frame_rate only when <= 60 fps; otherwise the rounded average, capped at 60 (VFR files reporting 1000/1). - wc -c instead of GNU stat; usage/-h; generic LOGO path in examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
- New rule 6: poster and gallery thumbnail show the system's effect; STILL_AT puts that moment at frame 0. - Safe area is 360x312 (poster on phones and the landing page are tighter than the project-page video); cite base.css for sizing. - Hidden-project rule no longer assumes #1469 has merged; notes that /media/ uploads keep their filenames. - Contact sheet writes sheet_%02d.jpg so long videos are fully covered. - Size rule matches the script and explains the stale admin help text. - Tool requirements; no personal paths in examples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
|
Fix round 1 for review 1. New head: How I tested: each should-fix was reproduced on the old head first, then the new scripts were run on synthetic lavfi sources with ffmpeg n8.0.1 (static) on Linux: 16:9, 2:1, 2560x1080, VFR (r 60/avg 42), 1278x720, BT.709-tagged, a 1 s clip, a busy and a noisy cut at Should-fix
Nits
Also
CIAll three checks pass on 🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5 |
jonfroehlich
left a comment
There was a problem hiding this comment.
Review round 2 (comment only). Head reviewed: 4b5949d1c275e2ac8062c6e28a5e59da1fcd6f5b. Range: a9be7aedf52bf44ac8b7e6359dc7eea0f16d9f0d..4b5949d1c275e2ac8062c6e28a5e59da1fcd6f5b (9a6c83f scripts, 4b5949d playbook).
Summary: no blocking findings. All of S1 to S8 and N1 to N8 are closed, and I found no regressions. STILL_AT works for valid values. One new should-fix: an invalid STILL_AT is silently ignored. Four nits.
How I tested: same setup as round 1 (ffmpeg n8.0.1 static on Linux, synthetic sources, headless Chromium for rendering). I re-ran every round-1 case against the new head. Nothing was run on macOS, Firefox or Safari.
Round-1 findings
| # | Status | What I checked at the new head |
|---|---|---|
| S1 size cap | Closed | Busy 12 s cut at speed 0.5: crf=31, 3,113,763 bytes, WARNING on stderr, exit 0. Same cut at 0.3: 4,669,208 bytes, ERROR, exit 3, files kept. Header, playbook and script agree on 2.5 MB / 4 MB, and #1468 does state those two numbers. |
S2 GNU stat |
Closed | Ran both scripts with PATH holding only bash sed wc tr mkdir rm head awk ffmpeg ffprobe plus a stat that rejects -c (so no python3, realpath or GNU stat): exit 0, CRF 27 chosen. Output is byte-identical with gawk, mawk and busybox awk. |
| S3 wider than 2:1 | Closed | 2560x1080, 2000x1000, 1920x1080 and 1278x720 all give 1600x800. ypos 0 and 1 give identical files for the wide source and different files for 16:9, as the header says. |
| S4 VFR frame rate | Closed | The r_frame_rate=1000/1 file now gives 30 fps, 328 frames, level 5.0, with the stderr note. 30, 24000/1001 and the r60/avg42 file are unchanged (330, 264 and 1260 frames; silence still ends at 5.000 s). |
| S5 poster colours | Closed | In Chromium at 1600 px, poster versus video on the red bar: BT.709-tagged source fa0100 / fd0002 (was e70001 / fd0002); untagged source fe1800 / ff1800; a BT.601-tagged HD source also matches. |
| S6 contact sheet | Closed | 400 s source gives sheet_01.jpg and sheet_02.jpg, last tile 00:06:35. A 290 s source gives a full sheet and a partial one. The new hero-sheet command in step 3 also runs. |
| S7 #1469 wording | Closed | #1469 is still open; the rule 8 text is true whether or not it merges. |
| S8 safe area | Closed | The 360x312 figure and the explanatory paragraph match my round-1 measurements. |
| N1, N2, N7 | Closed | Text read against the code. |
| N3 usage | Closed | -h / --help exit 0; 0, 4 and 9 arguments exit 2 with the usage line; a missing source exits 2 before creating the output directory. Same for add_prologue.sh (0 and 3 arguments exit 2). See R2-3 for a detail. |
| N4 short cuts | Closed | A 2.93 s cut exits 2 with a clear message; a 3.0 s cut gives a 2.0 s loop. |
| N5 leftovers | Closed | No -inter, -loop or -rot files after any failing run; exit codes survive the trap (2, 3, 234). |
| N6 SAR | Closed | 1278x720 gives SAR 1:1. |
N8 extra_vf order |
Closed | 2 fps source, speed 0.5, minterpolate: on the old head consecutive frames alternate about 60 dB / 48 dB (every second frame a repeat); on the new head they are uniform at 50 to 54 dB. |
No regressions: for the same arguments, the default (no STILL_AT) hero is byte-identical to the one the round-1 head produced, so the round-1 spec and seam checks carry over. Paths with spaces, a relative output directory, a relative source and invocation from another directory all still work.
STILL_AT
Valid values behave as documented:
- Frame 0 is the intended moment, and nothing is dropped or repeated. With
STILL_AT=4on a 300-frame loop, every one of the 300 frames matches the unrotated loop shifted by exactly 120 frames (minimum per-frame PSNR 40.5 dB; a shift of 119 or 121 gives 22.8 dB).STILL_AT=4.51rounds up to the next frame (shift 136). - Both joins are seamless. New wrap (last frame to frame 0) 18.4 dB and the old crossfade join, now mid-file, 18.3 dB, against 18.1 to 18.9 dB for ordinary consecutive pairs on this fast-changing pattern.
- Poster and thumbnail equal frame 0 (41.0 dB and 39.4 dB against frame 0; 19.3 dB against frame 1). The
STILL_AT=4poster matches unrotated frame 120, not frame 0. STILL_AT=0,0.0and an empty value give output byte-identical to the default. A value equal to or past the loop length exits 2.
Should-fix
R2-1. An invalid STILL_AT is silently ignored: the script exits 0 with an unrotated loop. Reproduced on a 4 s loop:
STILL_AT |
Result |
|---|---|
-1, abc, nan, inf |
exit 0, no message, output byte-identical to the unrotated run |
00:00:02.5, 2,5 |
awk syntax errors on stderr, then exit 0 with the unrotated output |
1e0 |
ffmpeg Unable to parse option value "1e0" as duration, exit 234 |
2s, " 2 " |
rotated, by accident of how awk reads them |
The 00:00:02.5 case is the likely one in practice: the step-3 sheet stamps each tile as HH:MM:SS.mmm, so that is the form the editor reads off before re-running. The run looks successful, and the poster is then not the payoff frame, which is the point of rule 6. Suggest rejecting anything that is not plain non-negative seconds before the first encode. This pattern accepts 4, 4.5, 0, .5 and rejects every value in the table above (pattern tested in bash, not wired into the script):
case $still in ''|*[!0-9.]*|*.*.*|.) echo "make_hero.sh: STILL_AT must be seconds into the loop, e.g. 4.5 (got '$still')" >&2; exit 2 ;; esacNits
- R2-2. A
STILL_ATin the last second of the loop gives a double-exposed poster. That second is the crossfade, so frame 0 becomes a blend of two moments. Reproduced withSTILL_AT=3.5on a 4 s loop: frame 0 is 34.3 dB from a 50/50 blend of the source at 4.5 s and 0.5 s, and 24.2 dB from either one alone. Worth one sentence in step 3 (pick a moment before the last second), or a warning from the script. - R2-3.
-h/--helpprint the usage to stderr, somake_hero.sh --help | lessshows nothing. The usage text is also pulled by line number (sed -n '4,5p','5,6p'), which breaks quietly if the header is edited. - R2-4. The PR description is stale. It still says "auto-CRF to stay ≤ ~2.7 MB" and does not mention the 4 MB cap, exit 3, or
STILL_AT. - R2-5. "They run on Linux and macOS" (playbook) and "Works with GNU and BSD/macOS userlands" (header) are still untested on macOS by either of us. I see no GNU-only or bash-4-only construct left, and the restricted-
PATHrun above supports that, but BSD awk and bash 3.2 were not exercised. The contact-sheet commands also need an ffmpeg withdrawtext(libfreetype), which the tools line does not mention.
Not checked
Real footage, HDR or 10-bit sources, macOS, Firefox and Safari, the actual lab logo animation, and YouTube's handling of the prologue output. The 2.5 MB / 4 MB policy itself is marked provisional by the author; I only checked that the script, header and playbook implement it consistently.
🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2
- make_hero.sh rejects a STILL_AT that is not non-negative seconds (exit 2, before any encode) and also accepts the H:MM:SS.mmm stamp the contact sheet prints. - Warns when STILL_AT falls in the loop's last (crossfade) second. - -h/--help print usage to stdout; usage is found by its "Usage:" block rather than by line number (both scripts). - Playbook and header: tested on Linux only, macOS untested; contact sheets need ffmpeg's drawtext (libfreetype). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
|
Fix round 2 for review 2. New head:
No regressions: without CI on 🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5 |
The site will cap the served banner video at 10 MB (#1468), so the script's hard cap matches it. The 2.5 MB target is unchanged. Rule 4 and step 3 of the playbook now say 10 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFUXRa2hBVnK4hXzY8dK68
Adds a playbook for publishing project pages with hero (banner) videos and official YouTube videos, based on the December 2026 batch of page updates.
docs/PROJECT_VIDEO_PLAYBOOK.md: the rules (no text in hero images/videos; one small 2:1 loop per project with poster + alt text; poster and gallery thumbnail show the system's effect; official video on the lab channel with the logo prologue; no identifiable participants; unpublished work stays hidden), why the spec follows from how the 500 px hero renders (safe area ~360x312), and step-by-step: find source → pick moment → render → YouTube with prologue →/adminentry.scripts/video/make_hero.sh: cut → largest 2:1 crop → 1600x800 H.264, no audio, faststart, crossfade loop. Tries CRF 27/29/31 for a 2.5 MB target: over the target it warns (exit 0); over the 10 MB hard cap it exits 3 (10 MB is the most the site will serve once Banner videos: enforce size/format at upload (reject or re-encode oversized videos) #1468 lands; the 2.5 MB target is unchanged).STILL_AT=<sec or H:MM:SS.mmm>rotates the seamless loop so the payoff moment is frame 0; invalid values exit 2. Also writes the 1600x500 poster and 1000x600 gallery thumbnail (colour-converted for JPEG).scripts/video/add_prologue.sh: prepends the lab logo animation (path viaLOGO), matching the source frame rate (capped at 60 for VFR files), H.264/AAC for YouTube.CLAUDE.md: one-line pointer to the playbook.Both scripts avoid GNU-only tools; tested on Linux only (macOS untested). Docs/scripts only; no app code changes. Related: #1468 (server-side enforcement of banner video size/format), #1469 (hide private projects from bios).
🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5