refactor: replace rust-ffmpeg with simple process call

This commit is contained in:
Elias Wendland
2026-07-16 16:50:40 +02:00
parent edfe5aab3e
commit f8b5372e2e
3 changed files with 41 additions and 48 deletions
-1
View File
@@ -48,7 +48,6 @@ clap = { version = "4.6.1", features = ["derive"] }
image = "0.25.10" image = "0.25.10"
infer = "0.16.0" infer = "0.16.0"
petgraph = "0.8.3" petgraph = "0.8.3"
rust_ffmpeg = "1.0.0"
tempfile = "3.27.0" tempfile = "3.27.0"
thiserror = "2.0.18" thiserror = "2.0.18"
tokio = { version = "1.52.3", features = ["rt", "rt-multi-thread"] } tokio = { version = "1.52.3", features = ["rt", "rt-multi-thread"] }
+16 -21
View File
@@ -13,7 +13,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::plugin::Plugin; use crate::plugin::Plugin;
use rust_ffmpeg::FFmpegBuilder;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
@@ -152,28 +151,24 @@ impl Plugin for PluginImpl {
tracing::debug!("Built ffmpeg arguments: {:?}", raw_args); tracing::debug!("Built ffmpeg arguments: {:?}", raw_args);
let rt = tokio::runtime::Runtime::new().map_err(|e| { tracing::trace!("Executing ffmpeg command...");
tracing::error!("Failed to create Tokio runtime: {}", e); let output = std::process::Command::new("ffmpeg")
.arg("-y") // Overwrite output files without asking
.arg("-i")
.arg(&in_path)
.args(&raw_args)
.arg(&temp_out_path)
.output()
.map_err(|e| {
tracing::error!("Failed to execute ffmpeg: {}", e);
e.to_string() e.to_string()
})?; })?;
rt.block_on(async {
tracing::trace!("Executing FFmpegBuilder..."); if !output.status.success() {
FFmpegBuilder::new() let err = String::from_utf8_lossy(&output.stderr);
.map_err(|e| { tracing::error!("ffmpeg execution failed: {}", err);
tracing::error!("Failed to init FFmpegBuilder: {}", e); return Err(format!("ffmpeg failed: {}", err));
e.to_string() }
})?
.input_path(in_path)
.output_path(temp_out_path.to_path_buf())
.raw_args(raw_args)
.overwrite()
.run()
.await
.map_err(|e| {
tracing::error!("FFmpeg execution failed: {}", e);
e.to_string()
})
})?;
tracing::debug!("FFmpeg execution succeeded. Reading output file..."); tracing::debug!("FFmpeg execution succeeded. Reading output file...");
std::fs::read(&temp_out_path).map_err(|e| { std::fs::read(&temp_out_path).map_err(|e| {
+21 -22
View File
@@ -13,7 +13,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
use crate::plugin::Plugin; use crate::plugin::Plugin;
use rust_ffmpeg::FFmpegBuilder;
use std::io::Write; use std::io::Write;
use std::path::Path; use std::path::Path;
@@ -119,7 +118,11 @@ impl Plugin for PluginImpl {
let temp_out_path = temp_out.into_temp_path(); let temp_out_path = temp_out.into_temp_path();
let in_path = temp_in.path().to_path_buf(); let in_path = temp_in.path().to_path_buf();
tracing::trace!("Temp files created. In: {:?}, Out: {:?}", in_path, temp_out_path); tracing::trace!(
"Temp files created. In: {:?}, Out: {:?}",
in_path,
temp_out_path
);
let mut raw_args = vec![]; let mut raw_args = vec![];
match to { match to {
@@ -240,28 +243,24 @@ impl Plugin for PluginImpl {
tracing::debug!("Built ffmpeg arguments: {:?}", raw_args); tracing::debug!("Built ffmpeg arguments: {:?}", raw_args);
let rt = tokio::runtime::Runtime::new().map_err(|e| { tracing::trace!("Executing ffmpeg command...");
tracing::error!("Failed to create Tokio runtime: {}", e); let output = std::process::Command::new("ffmpeg")
.arg("-y") // Overwrite output files without asking
.arg("-i")
.arg(&in_path)
.args(&raw_args)
.arg(&temp_out_path)
.output()
.map_err(|e| {
tracing::error!("Failed to execute ffmpeg: {}", e);
e.to_string() e.to_string()
})?; })?;
rt.block_on(async {
tracing::trace!("Executing FFmpegBuilder..."); if !output.status.success() {
FFmpegBuilder::new() let err = String::from_utf8_lossy(&output.stderr);
.map_err(|e| { tracing::error!("ffmpeg execution failed: {}", err);
tracing::error!("Failed to init FFmpegBuilder: {}", e); return Err(format!("ffmpeg failed: {}", err));
e.to_string() }
})?
.input_path(in_path)
.output_path(temp_out_path.to_path_buf())
.raw_args(raw_args)
.overwrite()
.run()
.await
.map_err(|e| {
tracing::error!("FFmpeg execution failed: {}", e);
e.to_string()
})
})?;
tracing::debug!("FFmpeg execution succeeded. Reading output file..."); tracing::debug!("FFmpeg execution succeeded. Reading output file...");
std::fs::read(&temp_out_path).map_err(|e| { std::fs::read(&temp_out_path).map_err(|e| {