feat: add debug logging for external command extractors
parent
8f1a9f8473
commit
a2192f5143
|
@ -64,12 +64,17 @@ impl Extractor for MediaExtractor {
|
|||
)?;
|
||||
|
||||
// https://superuser.com/a/945604/409504
|
||||
let ffprobe_cmd = Command::new("ffprobe")
|
||||
let mut ffprobe = Command::new("ffprobe");
|
||||
let command = ffprobe
|
||||
.args(["-v", "error"])
|
||||
.args(["-show_entries", "format=duration"])
|
||||
.args(["-of", "default=noprint_wrappers=1:nokey=1"])
|
||||
.arg(file_path)
|
||||
.output()?;
|
||||
.arg(file_path);
|
||||
|
||||
trace!("Running `{:?}`", command);
|
||||
let now = std::time::Instant::now();
|
||||
let ffprobe_cmd = command.output()?;
|
||||
debug!("Ran `{:?}`, took {}s", command, now.elapsed().as_secs_f32());
|
||||
|
||||
if !ffprobe_cmd.status.success() {
|
||||
return Err(anyhow!(
|
||||
|
|
|
@ -49,25 +49,26 @@ impl<'a> Previewable for AudioPath<'a> {
|
|||
.map(String::to_owned)
|
||||
.unwrap_or_else(|| "860x256".into());
|
||||
|
||||
let thumbnail_cmd = Command::new("ffmpeg")
|
||||
let mut ffmpeg = Command::new("ffmpeg");
|
||||
let command = ffmpeg
|
||||
.args(["-i", &self.0.to_string_lossy()])
|
||||
.args([
|
||||
"-filter_complex",
|
||||
&format!(
|
||||
"[0:a]aformat=channel_layouts=mono, compand=gain=-2,
|
||||
showwavespic=s={dimensions}:colors={color},
|
||||
drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:color={color}"
|
||||
),
|
||||
&format!("[0:a]aformat=channel_layouts=mono,compand=gain=-2,showwavespic=s={dimensions}:colors={color},drawbox=x=(iw-w)/2:y=(ih-h)/2:w=iw:h=1:color={color}"),
|
||||
])
|
||||
.args(["-vframes", "1"])
|
||||
.arg(&*outfile.path().to_string_lossy())
|
||||
.arg("-y")
|
||||
.output()?;
|
||||
.arg("-y");
|
||||
|
||||
if !thumbnail_cmd.status.success() {
|
||||
trace!("Running `{:?}`", command);
|
||||
let now = std::time::Instant::now();
|
||||
let cmd_output = command.output()?;
|
||||
debug!("Ran `{:?}`, took {}s", command, now.elapsed().as_secs_f32());
|
||||
|
||||
if !cmd_output.status.success() {
|
||||
return Err(anyhow!(
|
||||
"Failed to render thumbnail: {:?}",
|
||||
String::from_utf8_lossy(&thumbnail_cmd.stderr)
|
||||
String::from_utf8_lossy(&cmd_output.stderr)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,13 +12,19 @@ pub struct VideoPath<'a>(pub &'a Path);
|
|||
|
||||
impl<'a> Previewable for VideoPath<'a> {
|
||||
fn get_thumbnail(&self, options: HashMap<String, String>) -> Result<Option<Vec<u8>>> {
|
||||
let duration_cmd = Command::new("ffprobe")
|
||||
let mut ffprobe = Command::new("ffprobe");
|
||||
let command = ffprobe
|
||||
.args(["-threads", "1"])
|
||||
.args(["-v", "error"])
|
||||
.args(["-show_entries", "format=duration"])
|
||||
.args(["-of", "default=noprint_wrappers=1:nokey=1"])
|
||||
.arg(self.0)
|
||||
.output()?;
|
||||
.arg(self.0);
|
||||
|
||||
trace!("Running `{:?}`", command);
|
||||
let now = std::time::Instant::now();
|
||||
let duration_cmd = command.output()?;
|
||||
debug!("Ran `{:?}`, took {}s", command, now.elapsed().as_secs_f32());
|
||||
|
||||
if !duration_cmd.status.success() {
|
||||
return Err(anyhow!(
|
||||
"Failed to retrieve file duration: {:?}",
|
||||
|
@ -38,7 +44,8 @@ impl<'a> Previewable for VideoPath<'a> {
|
|||
};
|
||||
|
||||
let outfile = tempfile::Builder::new().suffix(".webp").tempfile()?;
|
||||
let thumbnail_cmd = Command::new("ffmpeg")
|
||||
let mut ffmpeg = Command::new("ffmpeg");
|
||||
let command = ffmpeg
|
||||
.args(["-threads", "1"])
|
||||
.args(["-discard", "nokey"])
|
||||
.args(["-noaccurate_seek"])
|
||||
|
@ -47,8 +54,12 @@ impl<'a> Previewable for VideoPath<'a> {
|
|||
.args(["-vframes", "1"])
|
||||
.args(["-vsync", "passthrough"])
|
||||
.arg(&*outfile.path().to_string_lossy())
|
||||
.arg("-y")
|
||||
.output()?;
|
||||
.arg("-y");
|
||||
|
||||
trace!("Running `{:?}`", command);
|
||||
let now = std::time::Instant::now();
|
||||
let thumbnail_cmd = command.output()?;
|
||||
debug!("Ran `{:?}`, took {}s", command, now.elapsed().as_secs_f32());
|
||||
|
||||
if !thumbnail_cmd.status.success() {
|
||||
return Err(anyhow!(
|
||||
|
|
Loading…
Reference in New Issue