Last active
November 7, 2020 12:23
-
-
Save bzm3r/487add1885560ddebba1b7058b0a5140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn make_movie(width: i32, height: i32, framerate: i32, frames: i32) { | |
let mut surface = | |
ImageSurface::create(Format::ARgb32, width, height).expect("Couldn't create surface"); | |
let mut child = Command::new("cmd") | |
.args(&["/C", &format!( | |
"ffmpeg -f rawvideo -pix_fmt bgra -s {width}x{height} -i - -pix_fmt yuv420p -r {framerate} -y out.mp4", | |
width = width, | |
height = height, | |
framerate = framerate, | |
)]) | |
.stdin(Stdio::piped()) | |
.spawn() | |
.expect("failed to execute process"); | |
{ | |
// limited borrow of stdin | |
let child_stdin = child.stdin.as_mut().expect("failed to get stdin"); | |
(0..frames).for_each(|f| { | |
draw(&surface, f); | |
let d = surface.get_data().expect("Failed to get_data"); | |
child_stdin.write_all(&d).expect("Failed to write to file"); | |
}); | |
} | |
child.wait().expect("child process wasn't running"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment