Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: add ffmpeg integration for video and audio muxing functionality

Tonho86bf5b5c812f
diff --git a/src-tauri/src/core/ffmpeg.rs b/src-tauri/src/core/ffmpeg.rs
new file mode 100644
index 00000000..36484b62
--- /dev/null
+++ b/src-tauri/src/core/ffmpeg.rs
@@ -0,0 +1,43 @@
+use std::path::Path;
+
+use anyhow::anyhow;
+
+pub async fn is_ffmpeg_available() -> bool {
+ tokio::process::Command::new("ffmpeg")
+ .arg("-version")
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
+ .status()
+ .await
+ .map(|s| s.success())
+ .unwrap_or(false)
+}
+
+pub async fn mux_video_audio(video: &Path, audio: &Path, output: &Path) -> anyhow::Result<()> {
+ if let Some(parent) = output.parent() {
+ tokio::fs::create_dir_all(parent).await?;
+ }
+
+ let status = tokio::process::Command::new("ffmpeg")
+ .args([
+ "-y",
+ "-i",
+ &video.to_string_lossy(),
+ "-i",
+ &audio.to_string_lossy(),
+ "-c",
+ "copy",
+ &output.to_string_lossy(),
+ ])
+ .stdout(std::process::Stdio::null())
+ .stderr(std::process::Stdio::null())
+ .status()
+ .await
+ .map_err(|e| anyhow!("Falha ao executar ffmpeg: {}", e))?;
+
+ if !status.success() {
+ return Err(anyhow!("ffmpeg retornou código {}", status));
+ }
+
+ Ok(())
+}