app: cut miniatures for the clips grid

Each card's stage shows a frame of the clip now, cut once with ffmpeg
into a thumbs folder beside the clips and reused from there. The pass
runs one clip at a time on a thread, skips what is already on disk and
as new as its clip, and poll drops each finished picture into its card
as it lands. Deleting a clip takes its miniature with it.

The frame is the clip's first: an export starts on the moment the clip
was cut for, so the picture shows the action without a seek. A clip
re-exported over the same name keeps its old picture until restart,
because the image cache keys a file by its path alone.
This commit is contained in:
vhaudiquet committed 2026-11-22 18:52:57 +01:00
1 parent 3f82f87a81
commit 83ca4071d4
5 files changed
+196 -25

No files matched your search

+34 -22
View File
@@ -173,39 +173,50 @@ fn clip_card(app: &App, p: Paint, k: &Kit, layer: &mut Vec<El>, clip: &Clip, ind
col()
.key("card")
.w_full()
.child(stage(p, clip))
.child(stage(app, p, clip))
.child(footer(app, p, k, layer, clip, &card)),
)
}
/// The clip itself: the 16:9 box the card gives, on black, with the play mark over it. The
/// clip's own pictures land here later; the layout of the card is the same with or without.
fn stage(_p: Paint, _clip: &Clip) -> El {
col()
/// The clip itself: the 16:9 box the card gives. The miniature the thumbnail pass cuts fills
/// it once it has landed, and the play mark rides over it either way.
fn stage(app: &App, p: Paint, clip: &Clip) -> El {
let mut stage = col()
.key("stage")
.aspect_ratio(16.0 / 9.0)
.w_full()
.fill(Color::BLACK)
.child(
el().key("play-overlay")
.fill(Color::BLACK);
if let (Some(path), Some(thumbs)) = (&clip.thumb, &app.thumbs) {
let image = thumbs.file(path, 360.0, p.scale);
stage = stage.child(
el().key("thumb")
.absolute(0.0, 0.0)
.w_full()
.h_full()
.center()
.a11y_hidden()
.child(
el().key("play")
.size(40.0, 40.0)
.radius(20.0)
.center()
.fill(Color::WHITE.alpha(0.16))
.child(
rune::icon(&icons::PLAY, 18.0)
.color(Color::WHITE.alpha(0.9))
.a11y_hidden(),
),
),
)
.pixels(image.pixels()),
);
}
stage.child(
el().key("play-overlay")
.absolute(0.0, 0.0)
.w_full()
.h_full()
.center()
.a11y_hidden()
.child(
el().key("play")
.size(40.0, 40.0)
.radius(20.0)
.center()
.fill(Color::WHITE.alpha(0.16))
.child(
rune::icon(&icons::PLAY, 18.0)
.color(Color::WHITE.alpha(0.9))
.a11y_hidden(),
),
),
)
}
/// Who the clip stars and what game it came from, with share and the actions menu beside.
@@ -364,6 +375,7 @@ fn delete_confirmed(app: &mut App) {
return;
};
let clip = app.clips.remove(index);
let _ = std::fs::remove_file(crate::export::thumb_path(&clip));
match std::fs::remove_file(&clip.path) {
Ok(()) => app.notify("Clip deleted"),
Err(error) => {