aboutsummaryrefslogtreecommitdiff
path: root/transcoder/src
diff options
context:
space:
mode:
Diffstat (limited to 'transcoder/src')
-rw-r--r--transcoder/src/snippet.rs57
1 files changed, 35 insertions, 22 deletions
diff --git a/transcoder/src/snippet.rs b/transcoder/src/snippet.rs
index e9569da..969a2ec 100644
--- a/transcoder/src/snippet.rs
+++ b/transcoder/src/snippet.rs
@@ -24,37 +24,50 @@ pub async fn transcode(
move |mut output| async move {
let _permit = LOCAL_TRANSCODING_TASKS.acquire().await?;
info!("transcoding snippet {key}");
- let args = match enc {
+
+ let mut args = Vec::new();
+ match enc {
EncodingProfile::Video {
codec,
preset,
bitrate,
width,
- } => [
- "-vf".to_string(),
- format!("scale={width}:-1"),
- "-c:v".to_string(),
- codec.to_string(),
- "-preset".to_string(),
- format!("{preset}"),
- "-b:v".to_string(),
- format!("{bitrate}"),
- ]
- .to_vec(),
+ } => {
+ if let Some(width) = width {
+ args.push("-vf".to_string());
+ args.push(format!("scale={width}:-1"));
+ }
+ args.push("-c:v".to_string());
+ args.push(codec.to_string());
+ if let Some(preset) = preset {
+ args.push("-preset".to_string());
+ args.push(format!("{preset}"));
+ }
+ args.push("-b:v".to_string());
+ args.push(format!("{bitrate}"));
+ }
EncodingProfile::Audio {
codec,
bitrate,
- sample_rate: _,
- } => [
- // TODO resample?
- "-c:a".to_string(),
- codec.to_string(),
- "-b:a".to_string(),
- format!("{bitrate}"),
- ]
- .to_vec(),
+ sample_rate,
+ channels,
+ } => {
+ if let Some(channels) = channels {
+ args.push("-ac".to_string());
+ args.push(format!("{channels}"))
+ }
+ if let Some(sample_rate) = sample_rate {
+ args.push("-ar".to_string());
+ args.push(format!("{sample_rate}"))
+ }
+ args.push("-c:a".to_string());
+ args.push(codec.to_string());
+ args.push("-b:a".to_string());
+ args.push(format!("{bitrate}"));
+ }
EncodingProfile::Subtitles { codec } => {
- ["-c:s".to_string(), codec.to_string()].to_vec()
+ args.push("-c:s".to_string());
+ args.push(codec.to_string());
}
};
info!("encoding with {:?}", args.join(" "));