diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-02 19:46:08 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-02 19:46:08 +0200 |
commit | 839c1e1490e7cd856e6ada1dcfd82f3d4505c89c (patch) | |
tree | 2e3e929a8154f1239641da564ee05abf84bce19c /transcoder | |
parent | 15d1f6516e31d20ab69569b7d6b6589f4d8f4f7b (diff) | |
download | jellything-839c1e1490e7cd856e6ada1dcfd82f3d4505c89c.tar jellything-839c1e1490e7cd856e6ada1dcfd82f3d4505c89c.tar.bz2 jellything-839c1e1490e7cd856e6ada1dcfd82f3d4505c89c.tar.zst |
transcoding profiles
Diffstat (limited to 'transcoder')
-rw-r--r-- | transcoder/src/snippet.rs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/transcoder/src/snippet.rs b/transcoder/src/snippet.rs index 3cc9736..9253c2c 100644 --- a/transcoder/src/snippet.rs +++ b/transcoder/src/snippet.rs @@ -5,7 +5,7 @@ */ use jellybase::cache::async_cache_file; -use jellycommon::AssetLocation; +use jellycommon::{AssetLocation, EncodingProfile}; use log::info; use std::process::Stdio; use tokio::{ @@ -13,19 +13,9 @@ use tokio::{ process::{ChildStdin, Command}, }; -#[derive(Debug)] -pub enum Encoding { - Video { - codec: &'static str, - preset: u8, - bitrate: usize, - width: usize, - }, -} - pub async fn transcode( key: &str, - enc: Encoding, + enc: &EncodingProfile, input: impl FnOnce(ChildStdin), ) -> anyhow::Result<AssetLocation> { Ok(async_cache_file( @@ -33,7 +23,7 @@ pub async fn transcode( move |mut output| async move { info!("transcoding snippet {key}"); let args = match enc { - Encoding::Video { + EncodingProfile::Video { codec, preset, bitrate, @@ -49,6 +39,21 @@ pub async fn transcode( format!("{bitrate}"), ] .to_vec(), + EncodingProfile::Audio { + codec, + bitrate, + sample_rate: _, + } => [ + // TODO resample? + "-c:a".to_string(), + codec.to_string(), + "-b:a".to_string(), + format!("{bitrate}"), + ] + .to_vec(), + EncodingProfile::Subtitles { codec } => { + ["-c:s".to_string(), codec.to_string()].to_vec() + } }; info!("encoding with {:?}", args.join(" ")); @@ -65,7 +70,7 @@ pub async fn transcode( input(stdin); copy(&mut stdout, &mut output).await?; - + proc.wait().await.unwrap().exit_ok()?; info!("done"); Ok(()) |