refactor: improve logging
Release / check-release (push) Successful in 15s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m43s
CI / Build Linux (push) Successful in 1m56s
Release / check-release (push) Successful in 15s
Release / build_gnu (push) Skipped
Release / build_musl (push) Skipped
Release / build_windows (push) Skipped
Release / package_gnu (deb) (push) Skipped
Release / package_gnu (rpm) (push) Skipped
Release / package_musl (deb) (push) Skipped
Release / package_musl (rpm) (push) Skipped
Release / publish-release (push) Skipped
CI / Test (push) Successful in 1m43s
CI / Build Linux (push) Successful in 1m56s
This commit is contained in:
+41
-9
@@ -38,11 +38,15 @@ impl Plugin for PluginImpl {
|
||||
]
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self))]
|
||||
fn is_available(&self) -> bool {
|
||||
std::process::Command::new("ffmpeg")
|
||||
tracing::trace!("Checking availability of ffmpeg for ffmpeg_video plugin");
|
||||
let available = std::process::Command::new("ffmpeg")
|
||||
.arg("-version")
|
||||
.output()
|
||||
.is_ok()
|
||||
.is_ok();
|
||||
tracing::debug!("ffmpeg_video plugin available: {}", available);
|
||||
available
|
||||
}
|
||||
|
||||
fn familiarity(&self, _from: &str, to: &str) -> u8 {
|
||||
@@ -84,6 +88,7 @@ impl Plugin for PluginImpl {
|
||||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, input, temp_dir))]
|
||||
fn convert(
|
||||
&self,
|
||||
input: &[u8],
|
||||
@@ -91,19 +96,30 @@ impl Plugin for PluginImpl {
|
||||
to: &str,
|
||||
temp_dir: &Path,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
tracing::debug!("ffmpeg_video starting conversion: {} -> {}", _from, to);
|
||||
let mut temp_in = tempfile::Builder::new()
|
||||
.suffix(&format!(".{}", _from))
|
||||
.tempfile_in(temp_dir)
|
||||
.map_err(|e| e.to_string())?;
|
||||
temp_in.write_all(input).map_err(|e| e.to_string())?;
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to create temp input file: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
temp_in.write_all(input).map_err(|e| {
|
||||
tracing::error!("Failed to write to temp input file: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
|
||||
let temp_out = tempfile::Builder::new()
|
||||
.suffix(&format!(".{}", to))
|
||||
.tempfile_in(temp_dir)
|
||||
.map_err(|e| e.to_string())?;
|
||||
.map_err(|e| {
|
||||
tracing::error!("Failed to create temp output file: {}", e);
|
||||
e.to_string()
|
||||
})?;
|
||||
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);
|
||||
|
||||
let mut raw_args = vec![];
|
||||
match to {
|
||||
@@ -222,19 +238,35 @@ impl Plugin for PluginImpl {
|
||||
}
|
||||
}
|
||||
|
||||
let rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?;
|
||||
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| e.to_string())?
|
||||
.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| e.to_string())
|
||||
.map_err(|e| {
|
||||
tracing::error!("FFmpeg execution failed: {}", e);
|
||||
e.to_string()
|
||||
})
|
||||
})?;
|
||||
|
||||
std::fs::read(&temp_out_path).map_err(|e| e.to_string())
|
||||
tracing::debug!("FFmpeg execution succeeded. Reading output file...");
|
||||
std::fs::read(&temp_out_path).map_err(|e| {
|
||||
tracing::error!("Failed to read output file {:?}: {}", temp_out_path, e);
|
||||
e.to_string()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user