refactor: replace rust-ffmpeg with simple process call
This commit is contained in:
+18
-23
@@ -13,7 +13,6 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::plugin::Plugin;
|
||||
use rust_ffmpeg::FFmpegBuilder;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -152,28 +151,24 @@ impl Plugin for PluginImpl {
|
||||
|
||||
tracing::debug!("Built ffmpeg arguments: {:?}", raw_args);
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().map_err(|e| {
|
||||
tracing::error!("Failed to create Tokio runtime: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
rt.block_on(async {
|
||||
tracing::trace!("Executing FFmpegBuilder...");
|
||||
FFmpegBuilder::new()
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to init FFmpegBuilder: {}", e);
|
||||
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::trace!("Executing ffmpeg command...");
|
||||
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()
|
||||
})?;
|
||||
|
||||
if !output.status.success() {
|
||||
let err = String::from_utf8_lossy(&output.stderr);
|
||||
tracing::error!("ffmpeg execution failed: {}", err);
|
||||
return Err(format!("ffmpeg failed: {}", err));
|
||||
}
|
||||
|
||||
tracing::debug!("FFmpeg execution succeeded. Reading output file...");
|
||||
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/>.
|
||||
|
||||
use crate::plugin::Plugin;
|
||||
use rust_ffmpeg::FFmpegBuilder;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -119,7 +118,11 @@ impl Plugin for PluginImpl {
|
||||
let temp_out_path = temp_out.into_temp_path();
|
||||
|
||||
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![];
|
||||
match to {
|
||||
@@ -240,28 +243,24 @@ impl Plugin for PluginImpl {
|
||||
|
||||
tracing::debug!("Built ffmpeg arguments: {:?}", raw_args);
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().map_err(|e| {
|
||||
tracing::error!("Failed to create Tokio runtime: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
rt.block_on(async {
|
||||
tracing::trace!("Executing FFmpegBuilder...");
|
||||
FFmpegBuilder::new()
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to init FFmpegBuilder: {}", e);
|
||||
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::trace!("Executing ffmpeg command...");
|
||||
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()
|
||||
})?;
|
||||
|
||||
if !output.status.success() {
|
||||
let err = String::from_utf8_lossy(&output.stderr);
|
||||
tracing::error!("ffmpeg execution failed: {}", err);
|
||||
return Err(format!("ffmpeg failed: {}", err));
|
||||
}
|
||||
|
||||
tracing::debug!("FFmpeg execution succeeded. Reading output file...");
|
||||
std::fs::read(&temp_out_path).map_err(|e| {
|
||||
|
||||
Reference in New Issue
Block a user