nathanbabcock / ffmpeg-sidecar

Wrap a standalone FFmpeg binary in an intuitive Iterator interface. 🏍
MIT License
288 stars 21 forks source link

Can we just pass our own ffmpeg and ffprobe bin paths? #22

Closed revofusion closed 1 year ago

revofusion commented 1 year ago

Would be quite useful, as currently there is requirement for ffmpeg to be in either the path or right next to the rust binary

nathanbabcock commented 1 year ago

@revofusion yes, absolutely — in fact, I'd recommend it so that you have the most control over where the binary is stored in your project.

The FfmpegCommand struct has two constructors:

  //// Constructors
  pub fn new() -> Self {
    Self::new_with_path(ffmpeg_path())
  }

  pub fn new_with_path<S: AsRef<OsStr>>(path_to_ffmpeg_binary: S) -> Self {
    // Configure `Command`
    let mut inner = Command::new(&path_to_ffmpeg_binary);
    inner.stdin(Stdio::piped());
    inner.stderr(Stdio::piped());
    inner.stdout(Stdio::piped());

    // Configure `FfmpegCommand`
    let mut ffmpeg_command = Self { inner };
    ffmpeg_command.set_expected_loglevel();
    ffmpeg_command
  }

The first one just trivially passes the default path into new_with_path(). In your case, you can call new_with_path directly in order to pass any absolute or relative path string for your binary.