refactor: replace rust-ffmpeg with simple process call
This commit is contained in:
1 parent
edfe5aab3e
commit
f8b5372e2e
3 files changed
+41
-48
No files matched your search
+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| {
|
||||
|
||||
Reference in new issue
Block a user