Expected Behavior
Videos should show an animated webp thumbnail (or at minimum a static jpg frame) in the Image History pane, like they did before the ffmpeg upgrade. Only an ffmpeg upgrade changed on the system; no SwarmUI version change was made.
Actual Behavior
After upgrading ffmpeg to 9.0, video thumbnails in the Image History pane render as broken/blank images, on both desktop and mobile. Static image thumbnails are unaffected. The browser receives a response with Content-Type: image/jpg whose body is actually the raw video bytes (an MP4 container), which an
cannot render.
Steps to Reproduce
- Run SwarmUI on a system with ffmpeg 9.0+ (e.g. Arch Linux, pacman upgrade from ffmpeg 8.1.2-11 → 2:9.0-5).
- Ensure Server → UI → "Allow Animated Previews" is enabled.
- Generate a video (e.g. an .mp4 output via the minimax-h3 backend, or any text2video model).
- Open the Image History pane.
- Observe the new video's thumbnail is blank/broken. A static jpg preview file (.swarmpreview.jpg) exists next to the video, but no .swarmpreview.webp.
Debug Logs
No errors in the log
Other
Root cause analysis:
- ffmpeg deprecated -vsync in 5.1 and removed it in 9.0. The webp preview command in src/Accounts/UserImageHistoryHelper.cs (DoFfmpegPreviewGeneration) still passes -vsync 0, so with ffmpeg 9.0 the command exits non-zero and no .swarmpreview.webp is created. The static .swarmpreview.jpg step doesn't use -vsync, so it still succeeds.
- This exposes a second, compounding bug in GetOrCreatePreviewFor (src/Utils/OutputMetadataTracker.cs): when a video has a jpg preview but no webp, the fallback branch runs new Image(data, MediaType.GetByExtension(ext)) with the video's extension (mp4). ToMetadataJpg() returns null for video media types, so the cached preview entry stores null data, and ViewOutput (src/Core/WebServer.cs) then serves the raw MP4 file bytes labeled as image/jpg — which the browser can't display.
Suggested fix:
- In DoFfmpegPreviewGeneration, replace -vsync 0 with -fps_mode passthrough. Since ffmpeg < 5.1 has -vsync but no -fps_mode, and ≥ 9.0 has -fps_mode but no -vsync, make it version-agnostic (detect version, or try -fps_mode passthrough first and fall back to -vsync 0).
- In GetOrCreatePreviewFor, fix the fallback so a video with only a jpg preview serves that jpg directly instead of routing it through ToMetadataJpg() with the source file's video media type.
- After the fix, users with already-cached broken preview entries need to run Reset All Metadata (Utilities tab) or wait for the 24h preview cache to expire so previews regenerate.
Added patches for the suggested changes:
fix_ffmpeg_vsync.patch
fix_preview_fallback.patch
Expected Behavior
Videos should show an animated webp thumbnail (or at minimum a static jpg frame) in the Image History pane, like they did before the ffmpeg upgrade. Only an ffmpeg upgrade changed on the system; no SwarmUI version change was made.
Actual Behavior
After upgrading ffmpeg to 9.0, video thumbnails in the Image History pane render as broken/blank images, on both desktop and mobile. Static image thumbnails are unaffected. The browser receives a response with Content-Type: image/jpg whose body is actually the raw video bytes (an MP4 container), which an
cannot render.
Steps to Reproduce
Debug Logs
No errors in the log
Other
Root cause analysis:
Suggested fix:
Added patches for the suggested changes:
fix_ffmpeg_vsync.patch
fix_preview_fallback.patch