Repository navigation
feat(preview): play animated WebP previews - #2734
Conversation
Animated WebP files showed only their first frame because every WebP went to the still-image decoder. A local WebP whose header declares an animation now plays in the media sandbox, like a GIF, when the runtime FFmpeg has the webp_anim decoder (9.0 or newer, asked once per process). With an older FFmpeg it keeps the still preview. FFmpeg's animated WebP demuxer reports no duration and cannot seek, so -stream_loop stalls and -ss skips to the end. The period comes from the container's frame durations instead, short animations loop with the loop filter ahead of the 30 fps conversion within a 256 MiB frame budget, and offsets are reached by decoding and trimming. Refs lgse#2710
The frame budget multiplied the frame count by a canvas size read from an untrusted header. A 16,384-frame file declaring a 16,777,216 pixel square canvas wraps to zero bytes, which panics a debug build and passes the budget in a release build. Refs lgse#2710
Split the RIFF walk into header and chunk readers, name the software-only, animation and demuxer-loop conditions, pass the probe request as a struct, move the WebP routing out of classify, and share one long-animation assertion between the GIF and WebP playback tests. No behaviour changes. Refs lgse#2710
Review and cleanupMerged Review against the description and #2710. There were no earlier review comments or threads.
Fixes pushed
Tests. None removed. The parser, decoder-listing, command and real-FFmpeg playback tests each fail on a realistic regression. Manual check in the pinned QA container (
Validation
Not blocking
CI: the fork's run needed maintainer approval; approved and in progress for |
The 100 ms flush timer from lgse#2634 stayed attached to the default main context after its browser was dropped. Its closure is bound to the thread that created it, so the next test thread that iterated the context fired it and glib's thread guard aborted the test binary. This failed Rust tests shard 0 in the local_departures monitor test on unrelated pull requests. Refs lgse#2710
|
CI fix pushed: Rust tests shard 0 failed twice on this PR, both times in The cause is the 100 ms flush timer added in #2634: it stayed attached to the default main context after its New test
|
…reviews feat(preview): backport animated WebP preview updates (#2734)
Description
Animated WebP files showed only their first frame: every WebP went to the still-image decoder. A local WebP whose header declares an animation (the VP8X animation flag) now plays in the media sandbox the way a GIF does, looping from the start with only the play/pause control.
It depends on the runtime FFmpeg having the
webp_animdecoder, which arrived in FFmpeg 9.0. Strata asksffmpeg -decodersonce per process; with an older FFmpeg the file keeps today's still preview, so nothing regresses on distributions that have not moved to 9.0 yet.FFmpeg's animated WebP demuxer reports no duration and cannot seek:
-stream_loopstalls and-ssskips to the end. So for this format only:loopfilter, placed before the 30 fps conversion so it holds source frames, within a 256 MiB budget (and FFmpeg's 32,767-frame limit); a larger one plays once;GIF commands are unchanged.
docs/preview-sandbox.mdanddocs/preferences.mddescribe the new behaviour.Validation notes: the new playback test needs FFmpeg 9 (the pinned test image has 9.0.1), so a native run on an older FFmpeg fails it rather than skipping.
scripts/code-health.shwas not run because no CodeScene token was available.Visual evidence
N/A: no captures attached. In words: selecting an animated WebP shows it playing and looping in the preview pane with a single play/pause control, as GIFs already do; a still WebP looks the same as before.
How to test
ffmpeg -f lavfi -i testsrc2=size=320x240:rate=10:duration=2 -c:v libwebp_anim -loop 0 anim.webp, or use any animated WebP from the web..webpfor comparison.Expected result: the animated WebP plays and loops with only a play/pause control, and resumes in phase. The still WebP shows its usual image preview. With an FFmpeg older than 9.0, the animated file shows its first frame as before.
Related issue
Closes #2710