Can't get output of ffmpeg

Hi there! My code is:



extern crate scrap;
use std::io::Read;

fn main() {
    use scrap::{Capturer, Display};
    use std::io::ErrorKind::WouldBlock;
    use std::io::Write;
    use std::process::{Command, Stdio};

    let d = Display::primary().unwrap();
    let (w, h) = (d.width(), d.height());

    let child = Command::new("C:\\ffmpeg-20200601-dd76226-win64-static\\bin\\ffmpeg.exe")
        .args(&[
            "-s",
            &format!("{}x{}", w, h),
            "-f",
            "rawvideo",
            "-pixel_format",
            "bgr0",
            "-i",
            "-",
            "-codec",
            "h264",
            "-framerate",
            "60",
            "-"
        ])
        .stdin(Stdio::piped())
        .stdout(Stdio::inherit())
        .spawn()
        .expect("This example requires ffplay.");

    let mut capturer = Capturer::new(d).unwrap();
    let mut out = child.stdin.unwrap();
    // let mut stdout = child.stdout.unwrap();

    loop {
        match capturer.frame() {
            Ok(frame) => {
                // Write the frame, removing end-of-row padding.
                let stride = frame.len() / h;
                let rowlen = 4 * w;
                for row in frame.chunks(stride) {
                    let row = &row[..rowlen];
                    out.write_all(row).unwrap();
                }
            }
            Err(ref e) if e.kind() == WouldBlock => {
                // Wait for the frame.
            }
            Err(_) => {
                // We're done here.
                break;
            }
        }
    }
}

So, I pipe screenshots into ffmpeg input, but I can't get output:

[NULL @ 000001b1992c33c0] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument ```

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.