refactor: replace rust-ffmpeg with simple process call
This commit is contained in:
@@ -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"] }
|
||||||
|
|||||||
+18
-23
@@ -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")
|
||||||
e.to_string()
|
.arg("-y") // Overwrite output files without asking
|
||||||
})?;
|
.arg("-i")
|
||||||
rt.block_on(async {
|
.arg(&in_path)
|
||||||
tracing::trace!("Executing FFmpegBuilder...");
|
.args(&raw_args)
|
||||||
FFmpegBuilder::new()
|
.arg(&temp_out_path)
|
||||||
.map_err(|e| {
|
.output()
|
||||||
tracing::error!("Failed to init FFmpegBuilder: {}", e);
|
.map_err(|e| {
|
||||||
e.to_string()
|
tracing::error!("Failed to execute ffmpeg: {}", e);
|
||||||
})?
|
e.to_string()
|
||||||
.input_path(in_path)
|
})?;
|
||||||
.output_path(temp_out_path.to_path_buf())
|
|
||||||
.raw_args(raw_args)
|
if !output.status.success() {
|
||||||
.overwrite()
|
let err = String::from_utf8_lossy(&output.stderr);
|
||||||
.run()
|
tracing::error!("ffmpeg execution failed: {}", err);
|
||||||
.await
|
return Err(format!("ffmpeg failed: {}", err));
|
||||||
.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| {
|
||||||
|
|||||||
+23
-24
@@ -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")
|
||||||
e.to_string()
|
.arg("-y") // Overwrite output files without asking
|
||||||
})?;
|
.arg("-i")
|
||||||
rt.block_on(async {
|
.arg(&in_path)
|
||||||
tracing::trace!("Executing FFmpegBuilder...");
|
.args(&raw_args)
|
||||||
FFmpegBuilder::new()
|
.arg(&temp_out_path)
|
||||||
.map_err(|e| {
|
.output()
|
||||||
tracing::error!("Failed to init FFmpegBuilder: {}", e);
|
.map_err(|e| {
|
||||||
e.to_string()
|
tracing::error!("Failed to execute ffmpeg: {}", e);
|
||||||
})?
|
e.to_string()
|
||||||
.input_path(in_path)
|
})?;
|
||||||
.output_path(temp_out_path.to_path_buf())
|
|
||||||
.raw_args(raw_args)
|
if !output.status.success() {
|
||||||
.overwrite()
|
let err = String::from_utf8_lossy(&output.stderr);
|
||||||
.run()
|
tracing::error!("ffmpeg execution failed: {}", err);
|
||||||
.await
|
return Err(format!("ffmpeg failed: {}", err));
|
||||||
.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| {
|
||||||
|
|||||||
Reference in New Issue
Block a user