Repository navigation
#762: import animated WebP as footage with its frames - #768
Merged
Merged
Conversation
Problem: an animated WebP (e.g. ffmpeg -c:v libwebp_anim) imported as a still and showed only its first frame; probe_bytes handed every WebP to the still path. Found while measuring storytold#719. Fix: a webp_anim module, following the animated GIF path. Probing reads the RIFF chunk headers (VP8X animation and alpha flags, one ANMF per frame) and describes a WebP with two or more frames as Video footage (codec "WebP", alpha Straight or Ignore from VP8X). Frame delays give the rate: delays within 1 ms of each other read as the standard rate they round to (24, 25, 29.97...), else 1000 / gcd of the delays so uneven timing is exact; delays of 10 ms or less count as 100 ms as in browsers. Frames are decoded once with the image crate's WebP AnimationDecoder and cached in the pool's existing GIF slot; gif_anim::Anim now keeps frame starts as Ticks and serves both formats. Canvas x frames beyond the existing memory cap is refused before decoding; a damaged tail keeps the frames before it; a file without frames is a clear decode error. Still WebP stays a still. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 11, 2026
Member
|
Merged. Thank you for the contribution, @vangel76! If you haven't already, come join us on Discord: https://discord.gg/artcraft. It's the best place to discuss what you're working on next and to coordinate with other contributors. |
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.
Fixes #762.
Found while measuring #719.
Problem
An animated WebP (for example one with alpha made by
ffmpeg -c:v libwebp_anim -loop 0) imported as a still and showed only its first frame:probe_bytessent every WebP down the still path. Animated GIF already plays its frames throughgif_anim.Fix
crates/media/src/webp_anim.rs, following the animated GIF path:VP8Xanimation and alpha flags, plus oneANMFchunk per frame. A WebP with two or more frames becomesVideofootage with codecWebP. Alpha isStraightwhen the VP8X alpha flag is set andIgnoreotherwise. A still WebP, or an animation with one frame, stays a still.imagecrate's WebPAnimationDecoder. No new dependency. Frames are cached in the pool's existing GIF slot.gif_anim::Animnow stores frame starts asTicks. It serves both formats:Anim::loadsends RIFF/WEBP data towebp_anim::load.is_gifis renamedis_animated. GIF behaviour is unchanged and its tests still pass.docs/file-format-parity.md: WebP row updated.Tests
an_animated_webp_is_a_movie_with_its_frames: a hand-built 3-frame animated WebP probes as Video with 20 fps, 0.2 s and Straight alpha. Frame N differs from frame 0, alpha is kept, and the last frame holds past the end. Onmainthis test fails because the footage is a Still.delays_rounded_to_milliseconds_read_as_the_standard_rate: covers the 24 fps and 29.97 fps snapping, exact uneven timing, and the 100 ms rule for very short delays.a_still_webp_stays_a_still: a lossless still WebP stays a still, and so does a one-frame animation.a_truncated_animated_webp_is_an_error_not_a_panic: several cut points; no panic, and a cut before the frame data is an error.a_huge_animation_is_refused_before_decoding: a 16384² × 10-frame header is refused.anim_a_1080.webp. This file is not committed. It probed as Video, 1920×1080, 24 fps, 1.0 s, and frame 12 differed from frame 0. A still WebP from the same set stays a Still.Gates
cargo fmt --check,clippy -p effectcraft-media --all-targets -D warnings, the fulleffectcraft-mediatests,cargo xtask layers, andcargo check -p effectcraft-media --target wasm32-unknown-unknownall passed. The fullcargo xtask ciwas not run because the machine is shared. No UI strings changed.Overlaps
probe.rs,pool.rsanddocs/file-format-parity.md:probe_bytessits a few lines below #745: import Targa (.tga) and Radiance HDR (.hdr) stills and sequences #755'sstill_formatline.pool.rschange is one line in theSome(mt)arm, below #745: import Targa (.tga) and Radiance HDR (.hdr) stills and sequences #755's hunk.What remains
Footage::loop_count. Footage plays once, as for GIF; Interpret Footage ▸ Loop still works..webpunder images and.gifunder video.🤖 Generated with Claude Code