Skip to content

Commit

Permalink
feat: allow configuring the name/path of ffprobe
Browse files Browse the repository at this point in the history
Fixes: #21
  • Loading branch information
lovesegfault authored and theduke committed Nov 24, 2023
1 parent cf7224f commit 504debb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn ffprobe(path: impl AsRef<std::path::Path>) -> Result<FfProbe, FfProbeErro
ffprobe_config(
Config {
count_frames: false,
ffprobe_bin: "ffprobe".into(),
},
path,
)
Expand All @@ -38,7 +39,7 @@ pub fn ffprobe_config(
) -> Result<FfProbe, FfProbeError> {
let path = path.as_ref();

let mut cmd = std::process::Command::new("ffprobe");
let mut cmd = std::process::Command::new(config.ffprobe_bin);

// Default args.
cmd.args([
Expand Down Expand Up @@ -71,6 +72,7 @@ pub fn ffprobe_config(
#[derive(Clone, Debug)]
pub struct Config {
count_frames: bool,
ffprobe_bin: std::path::PathBuf,
}

impl Config {
Expand All @@ -90,6 +92,7 @@ impl ConfigBuilder {
Self {
config: Config {
count_frames: false,
ffprobe_bin: "ffprobe".into(),
},
}
}
Expand All @@ -102,6 +105,13 @@ impl ConfigBuilder {
self
}

/// Specify which binary name (e.g. `"ffprobe-6"`) or path (e.g. `"/opt/bin/ffprobe"`) to use
/// for executing `ffprobe`.
pub fn ffprobe_bin(mut self, ffprobe_bin: impl AsRef<std::path::Path>) -> Self {
self.config.ffprobe_bin = ffprobe_bin.as_ref().to_path_buf();
self
}

/// Finalize the builder into a [`Config`].
pub fn build(self) -> Config {
self.config
Expand Down

0 comments on commit 504debb

Please sign in to comment.