Skip to content

feat(colorize): per-chunk colorization + rename --palette-colors to --colorize - #5

Merged
zeke merged 5 commits into
mainfrom
feat/colorize-per-chunk
Jun 3, 2026
Merged

zeke merged 5 commits into
mainfrom
feat/colorize-per-chunk

Conversation

@zeke

@zeke zeke commented Jun 3, 2026

Copy link
Copy Markdown
Owner

This PR adds a per-timestamp colorization mode and reworks the colorize flag.

Colorize

The boolean --palette-colors flag is replaced by --colorize {global,per-chunk} (no back-compat):

  • --colorize global keeps today's behavior: sample frames across the whole video and pick one text/box pair.
  • --colorize per-chunk samples a frame at each caption block's timestamp and applies that block's own text/box colors, so the colors track the imagery on screen as captions advance.

Per-chunk colors are applied as inline ASS \1c/\1a overrides; global and off keep using the style header. The color picker is factored into a pure select_colors() so both modes share the same WCAG AA contrast check and fallback. Color changes between blocks are hard cuts for now; tweening can come later.

The README gets a dedicated Colorize section, and AGENTS.md is updated to match.

Cleanup

caption.py never imported pysubs2, so it's removed from dependencies (the project now has no runtime third-party deps).

Tests, lint, CI

  • 27 subprocess-free unit tests (color math, contrast, time formatting, chunking, .wts parsing, select_colors, ASS generation). They run in well under a second.
  • Light ruff config and a pytest config under a dev dependency group.
  • A GitHub Actions workflow runs ruff and pytest on push to main and on PRs.

Both modes were verified end-to-end burning a real video with whisper + ffmpeg-full.

zeke added 5 commits June 2, 2026 19:25
…o --colorize

Replace the boolean --palette-colors flag with --colorize {global,per-chunk}.
global keeps the whole-video color pair; per-chunk samples a frame at each
caption block's timestamp and applies its own text/box colors via inline ASS
overrides. Factor the color picker into a pure select_colors() and document
the feature in its own README section.
…2 dep

caption.py never imported pysubs2, so remove it from dependencies. Add a dev
dependency group with pytest and ruff, a light ruff lint config, and 27
subprocess-free unit tests covering color math, contrast, time formatting,
chunking, .wts parsing, color selection, and ASS generation.
@zeke
zeke merged commit 32c9517 into main Jun 3, 2026
1 check 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.

1 participant