use a more simple way to check if ffmpeg exists

This commit is contained in:
jb-alvarado 2022-03-26 23:40:53 +01:00
parent e06c491a9c
commit 8ce545bb0d
3 changed files with 13 additions and 23 deletions

18
Cargo.lock generated
View File

@ -132,12 +132,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "either"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "fastrand"
version = "1.7.0"
@ -170,7 +164,6 @@ dependencies = [
"simplelog",
"tokio",
"walkdir",
"which",
]
[[package]]
@ -1103,17 +1096,6 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "which"
version = "4.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
dependencies = [
"either",
"lazy_static",
"libc",
]
[[package]]
name = "winapi"
version = "0.2.8"

View File

@ -22,7 +22,6 @@ shlex = "1.1"
simplelog = { version = "^0.11.2", features = ["paris"] }
tokio = { version = "1.16.1", features = ["rt-multi-thread"] }
walkdir = "2"
which = "4.2.5"
[target.x86_64-unknown-linux-musl.dependencies]
openssl = { version = "0.10", features = ["vendored"] }

View File

@ -14,7 +14,6 @@ use std::{
use regex::Regex;
use simplelog::*;
use which::which;
mod arg_parse;
mod config;
@ -350,9 +349,15 @@ pub async fn stderr_reader(std_errors: ChildStderr, suffix: String) -> Result<()
}
fn is_in_system(name: &str) {
// Check whether name is on PATH and marked as executable
if which(name).is_err() {
if let Ok(mut proc) = Command::new(name)
.stderr(Stdio::null())
.stdout(Stdio::null())
.spawn()
{
if let Err(e) = proc.wait() {
error!("{:?}", e)
};
} else {
error!("{} not found on system!", name);
exit(0x0100);
}
@ -403,6 +408,10 @@ fn ffmpeg_libs_and_filter() -> (Vec<String>, Vec<String>) {
}
}
if let Err(e) = ff_proc.wait() {
error!("{:?}", e)
};
(libs, filters)
}
pub fn validate_ffmpeg() {