diff --git a/src/dto.rs b/src/dto.rs index 012617f..51102ec 100644 --- a/src/dto.rs +++ b/src/dto.rs @@ -16,6 +16,7 @@ pub struct ConvertResponse { #[derive(TryFromMultipart)] #[try_from_multipart(rename_all = "camelCase")] pub struct ConvertRequest { + pub format: String, pub codec: String, pub codec_opts: Option, pub bit_rate: usize, diff --git a/src/server.rs b/src/server.rs index 61eda9f..13ce28f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -76,6 +76,7 @@ async fn enqueue_file( let task = Task::new( task_id, + req.format, req.codec, req.codec_opts, req.bit_rate, diff --git a/src/task.rs b/src/task.rs index 00a5fa8..6106d77 100644 --- a/src/task.rs +++ b/src/task.rs @@ -8,6 +8,7 @@ use tracing::{debug, error}; pub struct Task { id: uuid::Uuid, codec: String, + format: String, codec_opts: Option, bit_rate: usize, max_bit_rate: usize, @@ -21,6 +22,7 @@ pub struct Task { impl Task { pub fn new( id: uuid::Uuid, + format: String, codec: String, codec_opts: Option, bit_rate: usize, @@ -33,6 +35,7 @@ impl Task { ) -> Self { Task { id, + format, codec, codec_opts, bit_rate, @@ -62,11 +65,11 @@ impl Task { if self.codec_opts.is_some() { octx = format::output_as_with( &self.output_path, - &self.codec, + &self.format, params_to_avdictionary(&self.codec_opts.unwrap_or_default()), ); } else { - octx = format::output_as(&self.output_path, &self.codec); + octx = format::output_as(&self.output_path, &self.format); } let mut octx = match octx {