From cdcd9f7fe6543bef971b83ebefe84ed60167483a Mon Sep 17 00:00:00 2001 From: mykola2312 Date: Wed, 21 Feb 2024 14:35:07 +0200 Subject: [PATCH] mp3 converting with ffmpeg works --- src/dl/ffmpeg.rs | 5 +++-- src/main.rs | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dl/ffmpeg.rs b/src/dl/ffmpeg.rs index 1bdd2af..5e7d7d1 100644 --- a/src/dl/ffmpeg.rs +++ b/src/dl/ffmpeg.rs @@ -19,6 +19,7 @@ impl FFMpeg { output_path: &str, bitrate: u16, ) -> Result<(), SpawnError> { + let bitrate = format!("{}k", bitrate); let output = spawn( "ffmpeg", [ @@ -27,7 +28,7 @@ impl FFMpeg { "-codec:a", "libmp3lame", "-b:a", - "32k", + bitrate.as_str(), output_path, ], ) @@ -54,4 +55,4 @@ mod tests { assert_eq!(FFMpeg::round_mp3_bitrate(319.4), 320); assert_eq!(FFMpeg::round_mp3_bitrate(999.99), 320); } -} \ No newline at end of file +} diff --git a/src/main.rs b/src/main.rs index f38810a..b232435 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,10 @@ async fn main() -> anyhow::Result<()> { println!("abr {}", FFMpeg::round_mp3_bitrate(129.492)); + FFMpeg::convert_to_mp3("audio.m4a", "audio.mp3", 160) + .await + .expect("convert"); + Ok(()) //bot_main().await }