Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-VIEW-PHOTOGRID: the grid asks the image decoders for no thumbnail of a video (#2682)

insideTheFluxf867bcc5f9bf
diff --git a/crates/catalog/src/model.rs b/crates/catalog/src/model.rs
index b405e1db9..ef802e21a 100644
--- a/crates/catalog/src/model.rs
+++ b/crates/catalog/src/model.rs
@@ -458,6 +458,15 @@ impl Photo {
pub fn extension(&self) -> &str {
self.file_name.rsplit_once('.').filter(|(stem, _)| !stem.is_empty()).map_or("", |(_, ext)| ext)
}
+ /// A video clip (an MP4, a MOV, …), which the image decoders can't read. Besides the kind, the
+ /// format and the extension count: a Lightroom catalog lists its videos with the format `VIDEO`,
+ /// and libraries made before they were imported as videos hold them as images.
+ pub fn is_video(&self) -> bool {
+ const EXTENSIONS: [&str; 12] = ["mp4", "mov", "m4v", "avi", "mts", "m2ts", "3gp", "mkv", "webm", "wmv", "mpg", "mpeg"];
+ self.kind == MediaKind::Video
+ || self.format.eq_ignore_ascii_case("VIDEO")
+ || EXTENSIONS.iter().any(|e| self.extension().eq_ignore_ascii_case(e))
+ }
/// Width and height in pixels as the photo is shown: turned by its orientation and cut by its
/// crop. Straightening and Constrain Crop shrink the crop without changing its shape, so the
/// aspect is exact and the edges can read a little larger than an export.
@@ -554,6 +563,22 @@ mod edited_tests {
use super::*;
use lightcraft_develop::WbScale;
+ #[test]
+ fn a_video_is_known_by_its_kind_format_or_extension() {
+ let file = |name: &str, format: &str| Photo::new(PhotoId(1), Source::Demo { scene: 0 }, name, format, 10, 10, "2026-10-01T00:00:00");
+ let mut clip = file("a.jpg", "JPEG");
+ clip.kind = MediaKind::Video;
+ assert!(clip.is_video(), "by its kind");
+ assert!(file("clip", "video").is_video(), "by the format a Lightroom catalog gives videos");
+ for name in ["VID_1.mp4", "a.MOV", "b.m4v", "c.mts", "d.webm"] {
+ assert!(file(name, "").is_video(), "{name}");
+ }
+ // (a name without an extension, or a dot file, has none)
+ for (name, format) in [("a.jpg", "JPEG"), ("a.arw", "ARW"), ("a.heic", "HEIC"), ("mp4", ""), (".mov", "")] {
+ assert!(!file(name, format).is_video(), "{name}");
+ }
+ }
+
#[test]
fn raw_with_import_settings_is_not_edited() {
let mut p = Photo::new(PhotoId(1), Source::Demo { scene: 0 }, "a.arw", "ARW", 10, 10, "2026-10-01T00:00:00");
diff --git a/crates/engine/src/media.rs b/crates/engine/src/media.rs
index 292a9fb1e..8c5a170a1 100644
--- a/crates/engine/src/media.rs
+++ b/crates/engine/src/media.rs
@@ -1257,7 +1257,11 @@ impl crate::Session {
/// A grid/filmstrip thumbnail job: the long edge is rounded up to one of [`THUMB_SIZES`]
/// (≥ `long_edge`) and the result comes from / goes to the thumbnail cache (memory + disk).
+ /// `None` for a video: the image decoders can't read one, so none is asked to (issue #2682).
pub fn thumb_job(&mut self, id: PhotoId, long_edge: usize) -> Option<RenderJob> {
+ if self.catalog.photo(id).is_some_and(|p| p.is_video()) {
+ return None;
+ }
let b = thumb_bucket(long_edge);
let mut job = self.build_job(id, b, b, false, true, Some(b))?;
// (a thumbnail may develop a smaller copy of the raw image that the file keeps)
diff --git a/crates/ui-egui/src/render.rs b/crates/ui-egui/src/render.rs
index 1ed1071c2..5bb18ec5d 100644
--- a/crates/ui-egui/src/render.rs
+++ b/crates/ui-egui/src/render.rs
@@ -1447,6 +1447,39 @@ mod thumbnail_tests {
assert_eq!(app.renderer.queue.len(), 1);
}
+ /// Issue #2682: the grid sent each video to the image decoder for a thumbnail, which failed with
+ /// "unrecognised image format", and asked again on every pass. A video is known by its kind, by
+ /// the format a Lightroom catalog gives it, or by its extension; none asks for a render, so none
+ /// fails and its cell keeps the plain placeholder.
+ #[test]
+ fn a_video_asks_the_decoders_for_no_thumbnail() {
+ use lightcraft_catalog::MediaKind;
+ let clip = |name: &str, format: &str, kind: MediaKind| {
+ let mut p = Photo::new(PhotoId(1), Source::File { path: name.into() }, name, format, 1920, 1080, "2022-11-25");
+ p.kind = kind;
+ p
+ };
+ for video in [
+ clip("VID_20221125_083409_527.mp4", "MP4", MediaKind::Video),
+ clip("clip.MOV", "VIDEO", MediaKind::Image),
+ clip("20221223_100006.mp4", "", MediaKind::Image),
+ ] {
+ let name = video.file_name.clone();
+ let (mut app, work, ctx) = fixture_with(Session::new(), video);
+ for _ in 0..30 {
+ request(&mut app);
+ app.renderer.poll(&ctx, &mut app.session);
+ }
+ assert_eq!(app.renderer.thumb_jobs_built, 0, "{name}");
+ assert!(work.borrow().jobs.is_empty() && app.renderer.queue.is_empty(), "{name}: nothing is decoded");
+ assert_eq!(app.renderer.failure(Slot::Thumb(PhotoId(1))), None, "{name}: nothing failed, so the cell has no \"!\"");
+ }
+ // a photo is still asked for
+ let (mut app, _, _) = fixture();
+ request(&mut app);
+ assert_eq!(app.renderer.thumb_jobs_built, 1);
+ }
+
#[test]
fn resizing_the_disk_cache_keeps_textures_and_skips_rebuilds() {
let lib = std::env::temp_dir().join(format!("lc-ui-thumb-resize-{}", std::process::id()));
diff --git a/docs/whats-new.md b/docs/whats-new.md
index c09dddc09..b2fc44327 100644
--- a/docs/whats-new.md
+++ b/docs/whats-new.md
@@ -2,6 +2,14 @@
## 2026-10-23
+### Videos in the grid are no longer sent to the image decoders
+- A video in the library (an MP4 or MOV brought in from a Lightroom catalog) no longer asks the image decoders for a
+ grid thumbnail (issue #2682). They can't read one, so each video failed with "unrecognised image format", showed a
+ "!" and was tried again whenever the library changed, filling the log. Its cell now keeps the plain placeholder until
+ LightCraft can show video frames. A video is recognised by its type, by the format `VIDEO` that Lightroom catalogs
+ give videos, or by its extension (`.mp4`, `.mov`, `.m4v`, `.avi`, `.mts`, `.m2ts`, `.3gp`, `.mkv`, `.webm`, `.wmv`,
+ `.mpg`, `.mpeg`).
+
### Tab leaves the name field in New Album, New Smart Album and the name prompts
- In New Album, New Smart Album, Save Metadata Preset and the other dialogs with one name field, the field has the
keyboard focus when the dialog opens, and Tab now moves on to the check box, Cancel and OK (Shift+Tab goes back).