diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-01-24 23:06:33 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-01-24 23:06:33 +0100 |
| commit | 2bcccb18a6cb8bf836f57c3d86f759b19699def2 (patch) | |
| tree | ef55a10c6d9703677a983b8ca900fb4578a08eb3 /transcoder/src/thumbnail.rs | |
| parent | b2e88a8beabf04adc28947cf82996e8692a68b71 (diff) | |
| download | jellything-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.rs | 51 |
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") } |