Skip to content

Render each GAM video from the version that best matches the output - #34

Merged
davior merged 2 commits into
mainfrom
claude/determined-johnson-ci4a3k
Oct 29, 2026
Merged

davior merged 2 commits into
mainfrom
claude/determined-johnson-ci4a3k

Conversation

@davior

@davior davior commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

What

GAM can now hold standard-resolution versions of a video (davior/gam#56, recorded here as GAM-10). When a render resolves its media, it now asks GAM for each video's versions and reads the smallest file that is still at least as sharp as the frame shows it (render/media.py::pick_source).

  • A 1080p render of a 4K original reads its 1080p version. A preview (854×480) reads its 480p.
  • If the exact size was never made, it uses the next size up. If no version is big enough, it uses the original.
  • The fit changes what "sharp enough" means.
    • crop has to cover the frame, so both edges must reach it. A 16:9 video cropped into a 9:16 frame is shown 1920 tall, so it still reads the 4K original.
    • blur and pad only have to fit inside the frame, so either edge reaching it is enough. The same video fitted into that frame is shown 1080 wide, so the 720p (1280 wide) will do.
    • If any shot crops the asset, the asset counts as cropped.
  • A 2 px allowance covers versions that even-number rounding left a pixel short.
  • A clip reads its parent's versions. They share the parent's timeline, so the in and out points still hold.
  • If GAM has no versions route (a 404), the asset has no versions, or the call fails, the render uses the original exactly as before.
  • Versions are cached under their own key (<id>@1080) next to the original.
  • Size limit (merged with Render: name the oversized file, and let RENDER_MAX_FILE_MB be set #33): RENDER_MAX_FILE_MB is checked after the file is chosen, against that file's own size. A 4K original over the limit still renders when a version that fits exists, and an oversized version is refused before it downloads.

The editor's in-browser players still stream the original. Only renders change.

Tests

  • tests/test_render_versions.py (13 tests):
    • choosing the size: exact match, next size up, none big enough, none at all, crop vs fit in a vertical frame, the rounding allowance, unknown size;
    • resolving against the fake GAM: fetches only the version's file, falls back on a 404;
    • the size limit, in both directions.
  • The fake GAM gains a /versions route.
  • Run locally: pytest -q 778 passed. No frontend changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V1geD6HjkZNo9XQSHdawSb

GAM can now hold standard-resolution versions of a video (davior/gam#56).
A render asks for them and reads the smallest file that is still at least
as sharp as the frame shows it:

- a 1080p render of a 4K original reads its 1080p version, and a preview
  its 480p, for a fraction of the bytes to fetch and decode;
- the next size up when the exact one was never made, and the original
  when nothing is big enough;
- a shot cropped to fill the frame needs both edges to cover it, so a
  16:9 video cropped into a 9:16 frame still reads the original, while
  one fitted inside the same frame can use a far smaller file;
- a clip reads its parent's versions, which share its timeline;
- a GAM without versions (a 404), or a failed call, renders the
  original as before.

Versions are cached beside the original under their own key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1geD6HjkZNo9XQSHdawSb
main (#33) refuses a file GAM reports as over RENDER_MAX_FILE_MB before
downloading it; this branch chooses between the original and its
versions. The check now runs after the choice, on the chosen file, and a
version's own size counts as known. So a 4K original over the limit
still renders when a version that fits was made, and an oversized
version is refused before it downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1geD6HjkZNo9XQSHdawSb
@davior
davior marked this pull request as ready for review October 29, 2026 09:52
@davior
davior merged commit 63ec62f into main Oct 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants