use crate::error::Result;
use std::{
env::current_exe,
path::{Path, PathBuf},
};
pub fn ffmpeg_path() -> PathBuf {
let default = Path::new("ffmpeg").to_path_buf();
match sidecar_path() {
Ok(sidecar_path) => match sidecar_path.exists() {
true => sidecar_path,
false => default,
},
Err(_) => default,
}
}
pub fn sidecar_path() -> Result<PathBuf> {
let mut path = current_exe()?
.parent()
.ok_or("Can't get parent of current_exe")?
.join("ffmpeg");
if cfg!(windows) {
path.set_extension("exe");
}
Ok(path)
}
pub fn sidecar_dir() -> Result<PathBuf> {
Ok(
sidecar_path()?
.parent()
.ok_or("invalid sidecar path")?
.to_path_buf(),
)
}