Skip to content

Banner videos: enforce size/format at upload (reject or re-encode oversized videos) #1468

In review

Description

@jonfroehlich

Problem

Banner (hero) videos are uploaded as-is, with no size, codec, or container check beyond the extension/signature check in validate_video_upload (website/utils/upload_validators.py). The help text on Banner.video says "ideally 10MB or less", but nothing enforces it. Real examples on prod today:

  • BikeButler's only banner is a 56.8 MB .mov, served inside <source type="video/mp4"> (the type is hardcoded in website/templates/website/base.html), so every visitor downloads it and browsers that can't play QuickTime show nothing.
  • FlyMeThrough's three video banners total ~16.5 MB; SPECTRA ~12.7 MB; ImaginatAR ~7.6 MB; RAIS is a .mov.

Because every carousel slide stays in the DOM, each slide's video starts downloading at page load, so oversized banners hurt every project page view.

Proposal (to discuss)

  1. Reject at upload (cheap, synchronous): in the Banner admin, refuse a video that is over a hard cap (e.g. 10 MB) or isn't H.264 MP4, with a message pointing to the recommended spec. Probably via ffprobe (would need ffmpeg in the Dockerfile) or, minimally, a size check plus extension allowlist of mp4 only.
  2. Or re-encode (heavier): transcode oversized/.mov uploads to a web-friendly MP4 (1600x800, H.264, no audio, faststart, ~2.5 MB target). Doing this inside the admin request would be slow; it may belong in a management command (one-shot over existing banners, wired into docker-entrypoint.sh like the other startup commands) rather than on save.
  3. Related template fixes: derive the <source type> from the file extension instead of hardcoding video/mp4, and avoid preloading video for non-active slides / reduced-motion visitors.

Recommended hero-video spec (for the help text / docs)

  • 2:1 master at 1600x800 (the hero is 500 px tall at every width and center-cropped with object-fit: cover), 8–12 s seamless loop
  • H.264 High, yuv420p, no audio stream, -movflags +faststart, ≤ 2.5 MB target (4 MB hard cap)
  • Always upload a poster image with the video banner (poster is only emitted when Banner.image is set)

Open questions

  • Hard reject vs. auto re-encode vs. both (reject on upload + one-shot management command to fix existing banners)?
  • What cap? 10 MB matches the current help text; 4–5 MB is closer to best practice.
  • OK to add ffmpeg to the Docker image?

🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5

Activity

  1. jonfroehlich commented on Dec 2, 2026

    @jonfroehlich
    MemberAuthor

    Plan for #1468: convert banner videos on upload, cap the served file at 10 MB, fix the hero markup

    This plan was reviewed adversarially by Opus 5.5 over two rounds and revised; the reviewer's measurements are folded into section 3. Plan only: no code, commits or image changes have been made.

    1. What this changes, in short

    1. Upload: an editor may upload a large banner video (up to 250 MB and 60 s). The server keeps that original and produces a web-ready MP4 from it.
    2. Cap: no newly served banner video is over 10 MB (10,000,000 bytes). Loop-length clips come out near the playbook's 2.5 MB.
    3. Where it runs: in the background, after the admin request has returned.
    4. The original is kept with a server-generated name and is linked only from the admin. Public pages only ever use the converted file.
    5. Image: ffmpeg (with ffprobe) is added to the Docker image.
    6. Hero markup: <source type> follows the file, only the active slide's video loads, and visitors who prefer reduced motion load no video.
    7. Model: three small columns on Banner.

    2. Decisions so far

    Decision (Jon) How the plan uses it
    Re-encode oversized uploads on the server Every new upload goes through ffmpeg. Nothing is rejected for being large.
    10 MB is the max; larger uploads are fine 10 MB caps the served file, not the upload.
    Add ffmpeg to the Docker image Debian's ffmpeg package via apt.
    Template fixes are in scope Section 8.
    The plan's direction is approved, with 250 MB and 60 s as provisional limits Kept. Section 11 tests the 250 MB on the test server before a production tag.
    Keep the original upload Kept under media/ in its own subdirectory, server-generated name, admin-only link (section 7).

    Also accepted with the plan: no cropping on the server, a thread as the runner, Debian apt for ffmpeg, ffmpeg in the CI test job, existing banners as a follow-up, and raising #1470's cap to 10 MB. Section 13 lists what is new or changed since then.

    3. What was checked

    In the repo (at origin/master):

    • Banner.video is the only file field that holds video and the only user of validate_video_upload. Video records hold URLs. So this work applies to banners only.
    • Banners are edited in two places: BannerAdmin and BannerInline on the project form.
    • <video> appears once, in website/templates/website/base.html, with type="video/mp4" hard-coded and autoplay on every slide.
    • Servers run Gunicorn 23 with 3 sync workers and --timeout 120. There is no task queue.
    • Django sets no upload-size limit for files. Uploads over 2.5 MB stream to a temp file in the container.
    • The repo says nothing about the CSE proxy's body limit or timeouts.
    • CI's test job runs on a bare ubuntu-24.04 runner, not in the Docker image.

    Measured by the planner, in a throwaway container from the site image (Debian 12, ffmpeg 5.1.9, limited to 4 CPUs). Sources are synthetic and noisy, close to a worst case for size.

    • apt-get install --no-install-recommends ffmpeg adds 329 MB to the image.
    • One encoder pass with the settings in section 6:
    Source Time Output
    12 s, 1080p30 H.264 .mov, 32 MB 8.5 s 3.5 MB
    60 s, 1080p30 H.264 .mov, 150 MB 35.4 s 9.1 MB
    30 s, 4K30 HEVC .mov, 184 MB 44.4 s 14.2 MB without the bitrate ceiling; not re-run with it
    60 s, 4K30 HEVC .mov, 369 MB (over the ceiling) 72.0 s 28.5 MB without the bitrate ceiling; 9.0 MB with a 1,200 kbit/s ceiling (run at CRF 31)
    • ffprobe takes about 0.1 s per file, including the 184 MB one.
      • A file with a valid MP4 header followed by garbage makes ffprobe exit 0 with no video stream, so the check is "has a video stream", not the exit code.
      • .mov and .mp4 report the same format_name; the ftyp brand in the header tells them apart.
      • A phone-style rotated clip reports its width and height before rotation, with rotation: 90 in the stream's side data.
      • A text playlist renamed .mp4 is picked up by ffmpeg's HLS demuxer when the format is auto-detected, and refused when the demuxer is forced.
    • A stream copy (-c copy -an -map_metadata -1 -movflags +faststart) of a tagged H.264 .mov took 0.1 s. It removed the location and title tags and the audio track, and moved the index to the front.
    • The HLG-to-SDR filter chain in section 6 runs on this ffmpeg: a 6 s 1080p HLG-tagged clip converted in 7.9 s and came out 8-bit and tagged BT.709. Not tried on a real phone recording, and the colours were not inspected.

    Measured by the reviewer:

    • Gunicorn's worker timeout does cover the upload body (a slow client was cut off mid-upload at the timeout). This assumes the proxy streams the body, which is still unverified.
    • A daemon thread started by a request keeps running in a sync worker and does not trip the timeout.
    • In Chromium 148: a <source> gated with media is not requested under reduced motion, and is after the gate is removed and load() is called. A video with preload="none" and no autoplay is not requested until play(). A .mov source with no type is fetched. canPlayType('video/quicktime') is empty.
    • The Django admin loads the object again on every POST, so a form that leaves the video alone saves the video value current at that moment.

    Not verified:

    • Anything about the CSE proxy: its body limit, its timeouts, and whether it streams or buffers uploads.
    • Firefox and Safari. Section 8's behaviour is confirmed in Chromium only.
    • The production host's CPU speed. The timings are a guide.
    • How many existing banners are oversized.

    Test suite: 827 tests at origin/master. In the planner's run 18 errored, all from the planner's own setup (a tmpfs hid tracked fixture images), none in the banner, upload-validator, hero or version tests.

    4. The limits on an upload

    Limit Value Source
    Django file-upload size none settings.py
    Gunicorn worker timeout 120 s per request, upload included docker-entrypoint.sh; measured
    Gunicorn workers 3, sync docker-entrypoint.sh
    Proxy body limit and timeouts unknown CSE IT's configuration, not in the repo
    Largest upload known to have worked 56.8 MB the issue

    Inside the 120 s the request must now do three things: receive the upload, run ffprobe (0.1 s), and copy the original onto the media filesystem.

    Ceiling: 250 MB per upload (approved, provisional). 250 MB in 120 s needs a steady uplink of about 17 Mbit/s. A slower connection ends in a gateway error after two minutes with nothing saved. Two things soften that:

    • A check in the browser before the upload starts. A few lines of vanilla JS on the banner form compare the chosen file's size with the ceiling, show an error beside the field (role="alert") and stop the submit. The server checks again.
    • The help text says that files over about 100 MB need a fast connection.

    Section 11, step 5 tests real uploads at 100, 200 and 250 MB. Whether to raise the worker timeout is decision 6 in section 13.

    Length limit: 60 seconds (approved, provisional). At 60 s, 10 MB still allows about 1.3 Mbit/s, which holds up at 1600 px wide.

    5. Where the conversion runs: in the background

    A conversion cannot run inside the admin request. The upload alone can use the 120 s. One encoder pass on a 30 s 4K clip took 44 s on top of that. So the request stores the original and returns, and the conversion follows.

    Flow

    1. clean_video checks and decides. It changes nothing. Extension and magic bytes (the existing validator), the 250 MB ceiling, then ffprobe. An upload of 2.5 MB or less is held in memory, so it is written to a temp file for the probe. Refused here, as ordinary field errors: unreadable files, no video stream, over 60 s, a frame over 4096 px on a side, portrait video, and PQ HDR.
    2. The form's save() does the work, so nothing happens if another field or another inline fails validation. It stores the upload as Banner.video_original, sets video_conversion_started, clears any old error, and registers the job with transaction.on_commit. Banner.video is left as it was. When the form clears the video (the "Clear" box), save() also clears video_conversion_started and removes the original, so a job still running matches nothing when it finishes and cannot put the video back.
    3. After the commit, a daemon thread in that Gunicorn worker runs the job. A file lock (fcntl.flock on a file in the container's temp directory) makes jobs run one at a time across the three workers. The kernel releases the lock if the worker dies.
    4. The job stream-copies the original if it is already H.264, yuv420p, at most 1920×1080 and at most 10 MB. Otherwise it encodes (section 6).
    5. On success the MP4 is written to banner/videos/ under a server-generated name, and one UPDATE sets video and clears the job. The UPDATE is filtered on the banner id, the original's name and the start time, so a job that has been superseded changes nothing and its output is deleted.
    6. On failure the error is recorded on the banner. The original stays, and so does the previous video.
    7. The thread closes its database connection in a finally.

    Every new upload takes this path, including one that is already web-ready. That one is stream-copied in about a tenth of a second, which also strips metadata such as a recorded location.

    What the editor sees

    • The save returns as soon as the upload is stored, with a message: the video was received, is being converted, usually takes under a minute, and the banner keeps its current video or poster until then. If the banner has no image, the message also says to add one.
    • The banner list gets a Video column: converting…, then 2.3 MB .mp4, or conversion failed: <reason>, or interrupted. The change form shows the same in a read-only row, with a link to the original. The editor reloads to see it change; there is no polling.
    • A "Convert again from the original" action on the banner list. It is the way out of a failed or interrupted conversion, with no second upload.

    What visitors see

    Only ever the converted file. Until a conversion finishes they see the banner's previous video, or its poster image. A banner whose only media is an original that has not converted (no image, no video) is left out of the public carousels until it has something to show. One shared queryset filter does this for the landing page and the project page.

    Failure cases

    Failure Handling
    The container restarts, or the worker is killed, mid-conversion Nothing finishes the job, so video_conversion_started stays set. A job older than 30 minutes is shown as interrupted. "Convert again" restarts it from the kept original. No startup command is needed.
    ffmpeg hangs, or outlives a killed worker ffmpeg is run as timeout 300 nice -n 10 ffmpeg …, so it ends itself even with no parent.
    A second upload arrives before the first finishes It replaces the original and the start time. The first job's UPDATE matches no row and its output is deleted.
    The banner is deleted mid-conversion Same: the UPDATE matches nothing.
    The video is cleared mid-conversion Clearing also clears the start time and removes the original (flow step 2), so the UPDATE matches nothing. test_cleared_video_cancels_running_job guards this.
    A new banner's first upload is still converting and the editor wants to cancel it The video field is still empty, so there is no "Clear" box. The only way to cancel is to delete the banner. Accepted.
    A save lands in the instant between a job finishing and the admin writing the row The admin re-reads the banner on every POST, so this window is milliseconds. If it ever happens, the banner shows interrupted after 30 minutes and "Convert again" repairs it. No row lock is added.
    The transaction rolls back after the original was stored on_commit never fires. The stored original is unreferenced, like any file from a failed save today.

    Why a thread

    A thread needs no new service, no new container and nothing from CSE IT. A sidecar container, a startup command and a task-queue library were considered and rejected: each adds a process or a deploy-time step for a handful of uploads a month.

    6. Encoder settings

    Same family as make_hero.sh in #1470: H.264 High, yuv420p, no audio, +faststart, metadata stripped, a keyframe every 60 frames.

    timeout 300 nice -n 10 ffmpeg -v error -y -protocol_whitelist file -f <mov|matroska> -i <original>
      -map 0:v:0 -an -sn -dn
      -vf "scale=w='min(1600,iw)':h='min(900,ih)':force_original_aspect_ratio=decrease:force_divisible_by=2,setsar=1,fps=<rate>,format=yuv420p"
      -c:v libx264 -profile:v high -level 4.0 -pix_fmt yuv420p
      -crf 27 -maxrate <R>k -bufsize <2R>k -preset medium
      -g 60 -keyint_min 60 -sc_threshold 0 -threads 4
      -movflags +faststart -map_metadata -1 -map_chapters -1 <out>.mp4
    

    One pass, with a bitrate ceiling. R = min(2500, 72000 / duration) kbit/s. For easy footage CRF 27 decides and the file is small. For busy footage the ceiling decides: an 8 s loop tops out at the playbook's 2.5 MB, a 12 s loop at about 3.7 MB, and anything of 29 s or more at about 9 MB. Measured: 3.5 MB for the noisy 12 s clip and 9.1 MB for the noisy 60 s clip.

    This replaces the earlier CRF ladder of up to four passes. The worst case measured with the ladder was about 150 s for the 60 s clip; one pass took 35 s.

    If the result is over 10 MB, run once more with the ceiling at three quarters. If that is still over, or ffmpeg fails or times out, nothing is served: the error is recorded, the original stays, and the previous video stays live.

    Where the server differs from the script:

    make_hero.sh (authoring) Server (safety net) Why
    Framing crops to 2:1 no crop; fits inside 1600×900, never enlarges The server must not change the editor's framing.
    Frame rate forces 30 caps at 30, keeps lower rates Forcing 30 on a 24 fps source adds judder.
    Size control CRF 27/29/31 until under 2.5 MB one pass with a bitrate ceiling Predictable time on a shared host.
    Preset slow medium Same reason.
    Crossfade, poster, thumbnail yes no Authoring choices; the playbook stays the recommended route.
    Input handling trusted local file demuxer forced from the sniffed signature, -protocol_whitelist file, argv list with no shell, server-generated filenames The input is an upload.

    Frame rate. Same rule as #1470's script: use r_frame_rate when it is 60 or less, otherwise the rounded avg_frame_rate; then cap at 30. Phone clips are often variable-rate with a meaningless r_frame_rate.

    HDR. Recent iPhones record HLG HDR by default, so refusing HDR would turn away many phone clips. An HLG source gets a tone-mapping chain after the downscale:
    zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv.
    PQ (HDR10) sources are refused with a message. This is decision 1 in section 13.

    Portrait. A 1080×1920 clip would become 506×900 and then be enlarged about three times to fill a 2:1 hero. Portrait uploads (taller than wide after applying the rotation side data) are refused with a message pointing to the playbook. Decision 2.

    7. The original

    • Field: Banner.video_original, editable=False, stored under banner/videos/originals/ with a server-generated name (UniquePathAndRename(..., False) already produces one).
    • Never rendered publicly. It is not in base.html, the API or the sitemap. It is linked only from the banner's admin page. A test renders the landing and project pages and asserts originals/ does not appear.
    • Kept on success and on failure.
    • Deleted with the banner: the pre_delete receiver gains video_original, matching image and video.
    • When a banner's video is replaced: the superseded original is deleted once the new one is stored (decision 3). Originals are large.
    • Disk use. Up to 250 MB each on the shared media filesystem, which is snapshotted and retained for a year (docs/BACKUPS.md). At a handful of uploads a month this is a few GB a year.
    • Logging: log the banner id, sizes, bitrate and timings. Logs record ids and sizes, not user-supplied filenames.
    • delete_unused_files only touches publications, talks and posters, so it will not remove originals.

    8. Hero markup and carousel.js

    <source type>. A Banner.video_mime_type property: .mp4 and .m4v give video/mp4, .webm gives video/webm, anything else gives an empty string and the template omits type. Chromium does not claim support for video/quicktime, so a truthful type on a legacy .mov would make it skip a file it can play. With no type it fetches the file and decides (confirmed in Chromium).

    Inactive slides. Only the first (active) slide's <video> keeps autoplay. The others get preload="none". carousel.js already calls play() when a slide becomes active, which starts the load. Without JavaScript the carousel never leaves the first slide, and that slide still autoplays.

    Reduced motion. Each <source> gets media="(prefers-reduced-motion: no-preference)". With reduced motion set, the browser selects no source and fetches nothing; the poster shows. Browsers that do not support media here behave as today. Confirmed in Chromium; Firefox and Safari are checked in section 11, step 4.

    carousel.js. The Play control lets a reduced-motion visitor opt in, and it also restarts the auto-advance. So the gate must come off every slide the visitor then sees, not only the current one. The change is in setVideoPlayback: whenever a video is about to play, remove media from its <source> and call load() if the video has no source selected. Playing only happens when motion is not paused, so this covers each slide as it becomes active.

    Trade-off. A slide's video now starts loading when the slide appears. A banner with a poster shows the poster for that moment.

    9. Tests

    Tests come first. Those marked (guard) pass on origin/master today and are there to stay passing. All the others fail or do not exist on master.

    Rules for the conversion tests:

    • DatabaseTestCase is a TestCase, so transaction.on_commit callbacks do not run by themselves. Every conversion test wraps the save in self.captureOnCommitCallbacks(execute=True) and asserts how many callbacks were registered (one for an upload, none otherwise).
    • settings_test.py sets BANNER_VIDEO_CONVERT_INLINE = True, so the job runs inside the callback. One test turns that off, patches threading.Thread, and asserts a daemon thread is started with the job after the commit and not before.
    • No test needs a real ffmpeg except one skip-guarded class.

    website/tests/test_video_utils.py (unit):

    • test_probe_parses_ffprobe_json
    • test_probe_rejects_file_without_video_stream_even_when_ffprobe_exits_zero
    • test_probe_rejects_when_ffprobe_fails_or_times_out
    • test_rejects_clip_over_60_seconds / _frame_over_4096 / _pq_transfer / _unknown_duration
    • test_portrait_detected_from_rotation_side_data
    • test_stream_copy_allowed_for_small_h264_yuv420p and _refused_when_not_h264 / _not_yuv420p / _over_10mb / _larger_than_1080p
    • test_command_drops_audio_strips_metadata_and_sets_faststart
    • test_command_forces_demuxer_and_uses_no_shell
    • test_command_is_wrapped_in_timeout
    • test_bitrate_ceiling_follows_duration (8 s gives 2500, 60 s gives 1200)
    • test_frame_rate_rule_handles_variable_rate_and_caps_at_30
    • test_hlg_source_gets_tone_mapping_filters
    • test_retry_runs_once_when_result_is_over_cap
    • test_conversion_fails_when_retry_is_still_over_cap
    • test_conversion_fails_on_ffmpeg_error_and_on_timeout

    website/tests/test_banner_video_upload.py (integration; probe and encode patched):

    • test_upload_is_stored_as_original_not_as_video
    • test_original_name_is_server_generated
    • test_successful_conversion_sets_mp4_and_clears_job
    • test_failed_conversion_keeps_original_and_records_error
    • test_result_over_cap_is_never_served
    • test_superseded_job_changes_nothing
    • test_cleared_video_cancels_running_job
    • test_invalid_other_field_stores_nothing_and_registers_no_job
    • test_small_in_memory_upload_is_probed
    • test_unreadable_upload_is_a_field_error / test_upload_over_ceiling_is_a_field_error / test_clip_over_60s_is_a_field_error / test_portrait_upload_is_a_field_error
    • test_unchanged_video_is_not_probed_again
    • test_without_ffmpeg_small_upload_is_kept_and_large_one_rejected
    • test_inline_form_is_banner_admin_form
    • test_thread_started_after_commit_when_not_inline
    • test_job_older_than_30_minutes_reads_as_interrupted
    • test_convert_again_action_restarts_from_original
    • test_replacing_video_deletes_superseded_original
    • test_deleting_banner_deletes_original
    • test_public_pages_never_reference_original
    • test_banner_with_only_unconverted_original_is_not_shown
    • test_log_lines_use_ids_and_sizes
    • test_form_save_after_finished_conversion_keeps_new_video (guard)

    Additions to existing files:

    • test_upload_validators.py: test_banner_video_over_10mb_rejected, test_committed_banner_video_not_rechecked
    • test_hero_motion.py: test_source_type_follows_extension, test_mov_source_has_no_type_attribute, test_only_first_slide_autoplays, test_inactive_slides_have_preload_none, test_sources_are_gated_on_reduced_motion. The three existing tests are guards.
    • test_banner_admin.py: test_video_column_shows_size_converting_failed_and_interrupted
    • test_version_endpoint.py: test_reports_ffmpeg_availability

    Browser tests, new website/tests/test_hero_carousel_e2e.py (Playwright, skip-guarded like test_member_e2e.py, added to the CI e2e job). They count requests for banner video URLs. Each reduced-motion test first loads the same page with no preference and asserts the video is requested, so it cannot pass just because nothing was ever requested.

    • test_only_active_slide_video_is_requested
    • test_second_video_requested_when_its_slide_is_shown
    • test_no_video_requested_under_reduced_motion
    • test_play_control_loads_video_under_reduced_motion
    • test_after_play_under_reduced_motion_the_next_slide_also_loads

    The one class that needs ffmpeg, RealFfmpegTests: builds short clips with ffmpeg's test source and runs the real commands. It checks an encode (H.264, yuv420p, no audio, index at the front, inside 1600×900), a stream copy of a file carrying a location tag (tag gone), an HLG-tagged source (8-bit BT.709 out), and a garbage file (rejected). Skipped when ffmpeg is absent, so the suite stays green in today's image and on a laptop.

    Why have it: the command line is the product, and a mock cannot tell a working flag from a typo or from a flag one ffmpeg version lacks. The image has ffmpeg 5.1, CI's Ubuntu has 6.1, and #1460 will move the image to a newer Debian.

    CI: add ffmpeg to the test job's apt-get install line and set REQUIRE_FFMPEG=1 there, which turns that class's skip into a failure.

    Mutation targets

    Each of these edits must make a named test fail:

    1. Remove -an, +faststart, -map_metadata -1 or -pix_fmt yuv420p from the command.
    2. Skip the size check after encoding, or compare against the wrong constant.
    3. Drop -maxrate, or compute it without the duration.
    4. Store the upload as Banner.video on the convert path.
    5. Make upload_to keep the uploader's filename for the original.
    6. Delete the original after a failed conversion.
    7. Render video_original in base.html.
    8. Drop the original-name or start-time filter from the final UPDATE.
    9. Do the storing or the on_commit registration in clean_video.
    10. Start the thread before the commit.
    11. Probe a committed (unchanged) file again.
    12. Accept an over-10 MB upload when ffmpeg is missing.
    13. Remove form = BannerAdminForm from BannerInline.
    14. Allow a stream copy of a non-H.264 or over-10 MB file.
    15. Remove the timeout wrapper.
    16. Treat an old job as still converting.
    17. Template: hard-code video/mp4, put autoplay on every slide, or drop the media gate.
    18. carousel.js: remove the gate only from the slide that was active when Play was pressed (browser test).

    10. Files

    File Change
    Dockerfile add ffmpeg to the apt-get install list
    .github/workflows/test.yml ffmpeg and REQUIRE_FFMPEG=1 in test; the new module in e2e
    website/utils/video_utils.py (new) constants, probe, checks, command builder, encode with one retry, stream copy
    website/utils/banner_video_jobs.py (new) lock, thread start, the job, failure recording
    website/utils/upload_validators.py validate_banner_video_size (10 MB, new uploads only, using the existing _is_new_upload gate): a backstop on Banner.video
    website/models/banner.py video_original, video_conversion_started, video_conversion_error (all editable=False); video_mime_type; a status property; the shared "has something to show" filter; pre_delete; new help text
    website/admin/banner_admin.py BannerAdminForm, Video column, read-only status row with the original's link, "Convert again" action, save message, the size-check script
    website/admin/project_admin.py BannerInline.form, save message for inline banners
    website/static/website/js/banner_video_size_check.js (new) the pre-upload size check
    website/views/index.py, website/views/project.py use the shared filter
    website/views/version.py "ffmpeg": true/false
    website/templates/website/base.html, website/static/website/js/carousel.js section 8
    makeabilitylab/settings.py, settings_test.py inline conversion in tests; version bump at release
    docs section 14

    No startup command and nothing new in docker-entrypoint.sh.

    If ffmpeg is missing. The checkout can be ahead of the image during a deploy. The code checks shutil.which for ffmpeg and ffprobe. Without them, an upload of at most 10 MB is stored as Banner.video exactly as today, a larger one is refused with "this server cannot convert videos right now", the banner form says so in its help text, and /version.json reports "ffmpeg": false.

    Requires Updating Model Database: yes. Three new columns. Migrations are generated per environment at container start, so there is no migration file to commit.

    11. Rollout and what to verify on the test server

    1. Merge to master; the test server rebuilds the image. The first build is slow, because the new apt layer invalidates the cached pip layer.
    2. /version.json shows the new git_sha and "ffmpeg": true.
    3. In /admin on the test server, upload: a make_hero.sh output (stream-copied within a second); a 50 MB .mov (converted; the list shows the new size); a real iPhone HDR clip (converted, colours look right); a portrait clip, a garbage file renamed .mp4 and a 90 s clip (field errors). View the page source of the landing and project pages and confirm only the converted file is referenced.
    4. Open the landing page with the network panel in Chrome, Firefox and Safari: one video request on load, another when the slide changes, none with the OS set to reduce motion, and the next slide loads after pressing Play. Check a legacy .mov banner still plays in each.
    5. Upload files of about 100, 200 and 250 MB, on campus and on a throttled connection. Record the results in the issue. If uploads fail below 250 MB, lower the ceiling or raise the worker timeout before tagging.
    6. Tag for production.

    Local development needs an image rebuild (./run-docker-local-dev.sh --build). Until then the site runs in the no-ffmpeg mode.

    12. Out of scope

    • Converting the banners already on the site. The new Video column shows which are oversized; re-uploading one converts it. A bulk action can follow.
    • Deleting the served file an editor replaces. Existing behaviour for every upload field.
    • PQ (HDR10) tone mapping.
    • Generating a poster from the video.
    • Look-ahead preloading of the next slide.
    • Proxy settings. The worker timeout is decision 6.
    • Any change to Video, featured_video or the YouTube flow.

    13. Open decisions for Jon

    New or changed since the plan was approved. All of these are provisional: implementation goes ahead on the recommendation unless Jon says otherwise.

    # Question Recommendation
    1 HDR phone video. The earlier recommendation was to refuse it. Convert HLG, refuse PQ. iPhones record HLG by default, and the conversion runs on the image's ffmpeg. Step 3 of section 11 checks a real clip before tagging.
    2 Portrait video Refuse with a message. It cannot fill a 2:1 hero without heavy enlargement.
    3 When a banner's video is replaced, delete the superseded original? Yes. Originals are large and the old one is no longer used.
    4 One encoder pass with a bitrate ceiling, in place of the CRF ladder One pass. About a quarter of the worst-case encode time; loop-length clips still land near 2.5 MB.
    5 Leave a banner out of the public carousels while its only media is an unconverted original Yes. Otherwise a new video-only banner shows as an empty slide until it converts.
    6 Raise GUNICORN_TIMEOUT so slower connections can finish a 250 MB upload. The review confirmed the 120 s covers the upload. Still not in this PR. Decide from step 5's results; the alternative is a lower ceiling.
    7 Release number 2.36.0 (new feature).

    14. Docs to update

    • CLAUDE.md: a "Banner videos" paragraph (the pipeline, where the constants live, the kept original and that it is admin-only, disk use, the no-ffmpeg mode, the thread and the 30-minute rule); a line in the testing section on captureOnCommitCallbacks, the skip-guarded ffmpeg class and REQUIRE_FFMPEG.
    • docs/DEPLOYMENT.md: ffmpeg as an image dependency; the ffmpeg field in /version.json; the rebuild note.
    • Banner.video help text: what may be uploaded, that the server converts it to 10 MB or less, that large files need a fast connection, and to add a poster image.
    • docs/PROJECT_VIDEO_PLAYBOOK.md, if Add project page + hero video playbook and ffmpeg scripts #1470 has merged by then (section 15).
    • Issue labels: add Docker, Requires Updating Model Database and Accessibility.

    15. What #1470 needs

    #1470 uses a 2.5 MB target with a 4 MB hard cap, marked provisional. The target is right. One small commit on that branch brings the cap into line:

    • scripts/video/make_hero.sh: CAP_BYTES=4000000 becomes 10000000; the header comment and the two messages say 10 MB.
    • docs/PROJECT_VIDEO_PLAYBOOK.md: rule 4 and the step 3 bullet say 10 MB; the PR description too.

    Whichever PR merges second also rewrites two playbook sentences this work makes untrue: rule 4's "the admin form still says ideally 10MB or less and accepts .mov", and rule 2's "every slide's video downloads at page load". The playbook can add that the server converts whatever is uploaded and keeps the upload.

    🤖 Plan by Claude Code — Fable 5.2, claude-fable-5-2; adversarial plan review by Opus 5.5, claude-opus-5-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions