home
NOTE: Under Construction - I'm in the middle of upgrading my site and lots of stuff is kinda broken. Please forgive the mess.

Run An External Command In Rust

This is a basic example using ffprobe which gets a string back (after chomping off the newline)

April 2023
Code
use std::process::Command;

fn main() {
    let args: Vec<&str> = vec![
        "-v",
        "error",
        "-select_streams",
        "v:0",
        "-count_packets",
        "-show_entries",
        "stream=nb_read_packets",
        "-of",
        "csv=p=0",
        "some/path.mp4",
    ];
    let cmd_output = Command::new("ffprobe").args(args).output().unwrap();
    let frame_count_string = String::from_utf8(cmd_output.stdout).unwrap();
    let frame_count_str = frame_count_string.as_str().trim();
    dbg!(frame_count_str);
}
[TODO: Result]
═══ § ═══