#456 Desktop: thumbnails of videos, and of HEIC, AVIF and raw photos without a preview
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#456
- pull request
- state:merged
Closes #442. In the desktop app, a moment whose source is a video now shows a thumbnail. So does a HEIC, AVIF or raw photo that carries no JPEG preview of its own. No video decoder is bundled. **Where thumbnails come from, in order** (`src-tauri/src/thumbnails.rs`, new `system_thumbnails.rs`): 1. **Photos:** as before, their own EXIF preview, or the photo decoded and scaled down by the `image` crate. 2. **Videos:** the cover picture an MP4 or MOV carries (`moov/udta/meta/ilst/covr/data`), read in Rust. It handles both MP4's full-box `meta` and QuickTime's plain one. Box sizes are bounds-checked, there are at most 10,000 boxes per level, and covers are capped at 16 MB. 3. **Otherwise, the system's own thumbnail**, as its file manager shows it: - **Linux and the BSDs:** - First, the freedesktop cache (`~/.cache/thumbnails/{xx-large,x-large,large,normal}/ .png`), only if its `Thumb::URI` and `Thumb::MTime` match the file as it is now. - Otherwise, the first installed thumbnailer that takes the file's type, from `share/thumbnailers/*.thumbnailer` in `XDG_DATA_HOME` and `XDG_DATA_DIRS` (ffmpegthumbnailer, totem's, libheif's `heif-thumbnailer`, and so on). It's run as file managers run it, from its `Exec` line with `%i %u %o %s` filled in, with no shell and a 15-second limit. Types match through aliases, so `.heic` matches libheif's `image/heif`. - **macOS:** Quick Look (`qlmanage -t -s 256`). - **Windows:** the Shell's `IShellItemImageFactory` (thumbnail only, never the file type's icon). Its bitmap is read with `GetDIBits` and laid over white. **Unchanged design:** a picture from any of these is shrunk to 160 px, encoded as a JPEG, kept in the app's cache, and handed to the page as a `data:` URL. Nothing is saved or sent. **Editor:** `localPhoto` → `localPicture`, which also takes videos, so their markers ask for thumbnails. **File thumbnails** is now version 2, and its description names videos. **Dependencies:** `md-5 0.10.6` (Linux and the BSDs) and `windows 0.62.2` (Windows; already in the lock file through Tauri, now with the Shell and GDI features). Both are added to `THIRD_PARTY.md`. **Tests** - **Rust, 12 pass locally (3 new):** - an MP4 and a MOV with a blue cover give a 160×90 blue thumbnail; - a box that runs past its parent is refused, and a video with no cover gives none; - the freedesktop cache is used only while its URI and modification time match; - the `Exec` line is parsed, including quotes and field codes, and an unknown field code is refused; - a stand-in thumbnailer is run for the type it takes, one whose program is missing is passed over, and other types are left alone; - on macOS and Windows, a test asks the real system for a thumbnail of a PNG. It runs in the desktop CI jobs and couldn't be run here. - **End to end, by hand:** a real HEIC made with `heif-enc` went through this machine's actual `heif-thumbnailer` and came back as a 160×80 green thumbnail, as expected. The temporary test isn't committed. - **Windows and macOS code:** type-checked and Clippy-clean for `x86_64-pc-windows-msvc` and `aarch64-apple-darwin` in a scratch crate. A full cross-check of the app needs a Windows C compiler for `ring`. - **Unit and browser tests:** `local-files.test` covers videos and sounds. `populate-browser` now expects the video to be asked for, and it passes along with the browser suite. The unit tests pass, apart from `contents.test`'s known false failure about the local `node_modules` link. **Not covered:** a video the system can't picture (for example, Linux without ffmpegthumbnailer or totem) shows no thumbnail. The docs say so. Sound files still show none. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/456