Repository navigation
video-compressor: animated WebP output option - #351
Merged
Merged
Conversation
> Add animated webp as an option to the video-compressor tool (alternative to mp4)
A Format switch above the versions table picks MP4 or animated WebP. WebP
versions are encoded with libwebp_anim, loop forever (-loop 0; the webp muxer
defaults to playing once), have no audio, and get their own per-version
quality (0-100) plus encoder speed and max frame rate settings (15 fps by
default). Results preview as <img>, download as .webp, and the embed snippet
becomes an <img loading="lazy"> tag. The poster frame is now only extracted
before the first MP4 job.
Also adds a [hidden] { display: none !important } rule so hidden elements
with a display style (like the poster row) really hide.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EGZFbqVeWgoceoCSNFnfvY
Contributor
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
Owner
Author
|
WebP end up being a lot bigger than MP4, I'm going to land it anyway because it's an interesting demo of that fact. |
simonw
pushed a commit
that referenced
this pull request
Oct 1, 2026
test_webp_format_switches_settings, added in #351, has the same assumption as the <video> snippet test: newer Playwright Chromium reads the source size up front, so the <img> snippet carries width/height. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139NfxSqowttMWdKwMQ7hYM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude Opus 5.5
A Format switch above the versions table picks MP4 video or animated WebP.
In WebP mode:
-compression_level: 0, 2, 4 (the default) or 6. In testing, 6 took about 10× as long as 4 for files only 1–2% smaller.libwebp_anim, which stores only the parts of each frame that changed. They use-loop 0because ffmpeg's WebP output plays only once by default. They have no audio, and the WebP muxer writes no metadata.<img>and download as.webp. "Encode full version" keeps the format.'<img src="…webp" width height alt="" loading="lazy">', and the note above it says to fill in the alt text.libwebp_animhands its output to ffmpeg only at the very end, so ffmpeg's progress time stays at zero. The progress bar counts theframe=log lines instead.Results in both formats can sit side by side: switch format and generate again, and they're sorted by size. The poster frame is now extracted only before the first MP4 job, so a WebP-only run skips it.
Also adds a
[hidden] { display: none !important }rule, so hidden elements with a CSSdisplayvalue really hide. The poster row was showing while it was empty.Animated WebP is much larger than MP4. The 3-second, 128 KB test clip came out at about 290–350 KB as WebP, and the UI says so.
Tests
Two new Playwright tests in
tests/test_video_compressor.py:test_webp_format_switches_settingsruns offline. It covers the controls, quality header, filename hint, the<img>embed snippet (including the XHTML variant), and that each version keeps its WebP quality and CRF separately.test_animated_webp_encodeencodes a 1-second sample and then the full clip. It parses the RIFF chunks to check each file is animated, loops forever, is 640×360, has the right total length and has no EXIF/XMP/ICCP chunks. It also checks the command line, filenames and progress reporting, then encodes an MP4 alongside it.pytest tests/test_video_compressor.py -k "not jsquash": 8 passed.test_poster_webp_falls_back_to_jsquash_without_native_supportfails in the sandbox where this was written, onmainas well: it fetches@jsquash/webpfrom jsDelivr inside the browser, and that browser had no network access.🤖 Generated with Claude Code
https://claude.ai/code/session_01EGZFbqVeWgoceoCSNFnfvY