The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Run An External Command In Rust

TODO: Pull subtitle into page object
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);
}
Results
[src/main.rs:24] frame_count_str = "33366"

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Run An External Command In Rust

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

-- code
-- rust

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);
}


-- results

[src/main.rs:24] frame_count_str = "33366"


-- categories
-- Rust 
-- Command Line 

-- metadata
-- date: 2023-04-06 23:45:19
-- id: 2o58xfqt
-- site: aws
-- type: post
-- status: published