aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src/thumbnail.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-01-24 23:06:33 +0100
committermetamuffin <metamuffin@disroot.org>2026-01-24 23:06:33 +0100
commit2bcccb18a6cb8bf836f57c3d86f759b19699def2 (patch)
treeef55a10c6d9703677a983b8ca900fb4578a08eb3 /transcoder/src/thumbnail.rs
parentb2e88a8beabf04adc28947cf82996e8692a68b71 (diff)
downloadjellything-2bcccb18a6cb8bf836f57c3d86f759b19699def2.tar
jellything-2bcccb18a6cb8bf836f57c3d86f759b19699def2.tar.bz2
jellything-2bcccb18a6cb8bf836f57c3d86f759b19699def2.tar.zst
cache as object
Diffstat (limited to 'transcoder/src/thumbnail.rs')
-rw-r--r--transcoder/src/thumbnail.rs51
1 files changed, 26 insertions, 25 deletions
diff --git a/transcoder/src/thumbnail.rs b/transcoder/src/thumbnail.rs
index 85cb356..9207c30 100644
--- a/transcoder/src/thumbnail.rs
+++ b/transcoder/src/thumbnail.rs
@@ -1,5 +1,5 @@
use anyhow::{Context, Result};
-use jellycache::{cache_store, HashKey};
+use jellycache::{Cache, HashKey};
use log::info;
use std::{
io::Read,
@@ -7,31 +7,32 @@ use std::{
process::{Command, Stdio},
};
-pub fn create_thumbnail(path: &Path, time: f64) -> Result<String> {
- cache_store(
- format!("media/thumbnail/{}-{}.image", HashKey(path), time as i64),
- move || {
- info!("creating thumbnail of {path:?} at {time}s",);
+pub fn create_thumbnail(cache: &Cache, path: &Path, time: f64) -> Result<String> {
+ cache
+ .store(
+ format!("media/thumbnail/{}-{}.image", HashKey(path), time as i64),
+ move || {
+ info!("creating thumbnail of {path:?} at {time}s",);
- let mut proc = Command::new("ffmpeg")
- .stdout(Stdio::piped())
- .args(["-ss", &format!("{time}")])
- .args(["-f", "matroska", "-i", path.to_str().unwrap()])
- .args(["-frames:v", "1"])
- .args(["-c:v", "qoi"])
- .args(["-f", "image2"])
- .args(["-update", "1"])
- .arg("pipe:1")
- .spawn()?;
+ let mut proc = Command::new("ffmpeg")
+ .stdout(Stdio::piped())
+ .args(["-ss", &format!("{time}")])
+ .args(["-f", "matroska", "-i", path.to_str().unwrap()])
+ .args(["-frames:v", "1"])
+ .args(["-c:v", "qoi"])
+ .args(["-f", "image2"])
+ .args(["-update", "1"])
+ .arg("pipe:1")
+ .spawn()?;
- let mut stdout = proc.stdout.take().unwrap();
- let mut output = Vec::new();
- stdout.read_to_end(&mut output)?;
+ let mut stdout = proc.stdout.take().unwrap();
+ let mut output = Vec::new();
+ stdout.read_to_end(&mut output)?;
- proc.wait().unwrap().exit_ok()?;
- info!("done");
- Ok(output)
- },
- )
- .context("creating thumbnail")
+ proc.wait().unwrap().exit_ok()?;
+ info!("done");
+ Ok(output)
+ },
+ )
+ .context("creating thumbnail")
}