pub fn ffmpeg_is_installed() -> bool
Expand description
Verify whether ffmpeg is installed on the system. This will return true if there is an ffmpeg binary in the PATH, or in the same directory as the Rust executable.
Examples found in repository?
examples/download_ffmpeg.rs (line 11)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
fn main() -> anyhow::Result<()> {
use ffmpeg_sidecar::{
command::ffmpeg_is_installed,
download::{check_latest_version, download_ffmpeg_package, ffmpeg_download_url, unpack_ffmpeg},
paths::sidecar_dir,
version::ffmpeg_version_with_path,
};
use std::env::current_exe;
if ffmpeg_is_installed() {
println!("FFmpeg is already installed! 🎉");
println!("For demo purposes, we'll re-download and unpack it anyway.");
println!("TIP: Use `auto_download()` to skip manual customization.");
}
// Short version without customization:
// ```rust
// ffmpeg_sidecar::download::auto_download().unwrap();
// ```
// Checking the version number before downloading is actually not necessary,
// but it's a good way to check that the download URL is correct.
match check_latest_version() {
Ok(version) => println!("Latest available version: {}", version),
Err(_) => println!("Skipping version check on this platform."),
}
// These defaults will automatically select the correct download URL for your
// platform.
let download_url = ffmpeg_download_url()?;
let cli_arg = std::env::args().nth(1);
let destination = match cli_arg {
Some(arg) => resolve_relative_path(current_exe()?.parent().unwrap().join(arg)),
None => sidecar_dir()?,
};
// The built-in download function uses `reqwest` to download the package.
// For more advanced use cases like async streaming or download progress
// updates, you could replace this with your own download function.
println!("Downloading from: {:?}", download_url);
let archive_path = download_ffmpeg_package(download_url, &destination)?;
println!("Downloaded package: {:?}", archive_path);
// Extraction uses `tar` on all platforms (available in Windows since version 1803)
println!("Extracting...");
unpack_ffmpeg(&archive_path, &destination)?;
// Use the freshly installed FFmpeg to check the version number
let version = ffmpeg_version_with_path(destination.join("ffmpeg"))?;
println!("FFmpeg version: {}", version);
println!("Done! 🏁");
Ok(())
}