aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src
diff options
context:
space:
mode:
Diffstat (limited to 'transcoder/src')
-rw-r--r--transcoder/src/image.rs18
-rw-r--r--transcoder/src/snippet.rs6
-rw-r--r--transcoder/src/thumbnail.rs5
3 files changed, 12 insertions, 17 deletions
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs
index 5df21a9..20f7e0c 100644
--- a/transcoder/src/image.rs
+++ b/transcoder/src/image.rs
@@ -6,37 +6,33 @@
use crate::LOCAL_IMAGE_TRANSCODING_TASKS;
use anyhow::Context;
use image::imageops::FilterType;
-use jellybase::{cache::async_cache_file, AssetLocationExt};
-use jellycommon::AssetLocation;
+use jellybase::cache::{async_cache_file, CachePath};
use log::{debug, info};
use rgb::FromSlice;
use std::{
fs::File,
io::{BufReader, Read, Seek, SeekFrom},
+ path::PathBuf,
};
use tokio::io::AsyncWriteExt;
pub async fn transcode(
- asset: AssetLocation,
+ path: PathBuf,
quality: f32,
speed: u8,
width: usize,
-) -> anyhow::Result<AssetLocation> {
- let original_path = asset.path();
- let asset = asset.clone();
+) -> anyhow::Result<CachePath> {
Ok(async_cache_file(
&[
"image-tc",
- original_path.as_os_str().to_str().unwrap(),
+ path.clone().as_os_str().to_str().unwrap(),
&format!("{width} {quality} {speed}"),
],
move |mut output| async move {
let _permit = LOCAL_IMAGE_TRANSCODING_TASKS.acquire().await?;
- info!("encoding {asset:?} (speed={speed}, quality={quality}, width={width})");
+ info!("encoding {path:?} (speed={speed}, quality={quality}, width={width})");
let encoded = tokio::task::spawn_blocking(move || {
- let original_path = asset.path();
- let mut file =
- BufReader::new(File::open(&original_path).context("opening source")?);
+ let mut file = BufReader::new(File::open(&path).context("opening source")?);
// TODO: use better image library that supports AVIF
let is_avif = {
diff --git a/transcoder/src/snippet.rs b/transcoder/src/snippet.rs
index 5da1ae7..3632919 100644
--- a/transcoder/src/snippet.rs
+++ b/transcoder/src/snippet.rs
@@ -5,8 +5,8 @@
*/
use crate::LOCAL_VIDEO_TRANSCODING_TASKS;
-use jellybase::cache::async_cache_file;
-use jellycommon::{jhls::EncodingProfile, AssetLocation};
+use jellybase::cache::{async_cache_file, CachePath};
+use jellycommon::jhls::EncodingProfile;
use log::{debug, info};
use std::process::Stdio;
use tokio::{
@@ -21,7 +21,7 @@ pub async fn transcode(
key: &str,
enc: &EncodingProfile,
input: impl FnOnce(ChildStdin),
-) -> anyhow::Result<AssetLocation> {
+) -> anyhow::Result<CachePath> {
Ok(async_cache_file(
&["snip-tc", key, &format!("{enc:?}")],
move |mut output| async move {
diff --git a/transcoder/src/thumbnail.rs b/transcoder/src/thumbnail.rs
index 5baf888..9661fd0 100644
--- a/transcoder/src/thumbnail.rs
+++ b/transcoder/src/thumbnail.rs
@@ -1,11 +1,10 @@
use crate::LOCAL_IMAGE_TRANSCODING_TASKS;
-use jellybase::cache::async_cache_file;
-use jellycommon::AssetLocation;
+use jellybase::cache::{async_cache_file, CachePath};
use log::info;
use std::{path::Path, process::Stdio};
use tokio::{io::copy, process::Command};
-pub async fn create_thumbnail(path: &Path, time: f64) -> anyhow::Result<AssetLocation> {
+pub async fn create_thumbnail(path: &Path, time: f64) -> anyhow::Result<CachePath> {
Ok(async_cache_file(
&["thumb", path.to_str().unwrap(), &format!("{time}")],
move |mut output| async move {