pub fn start(
out_file: impl AsRef<OsStr>,
width: usize,
height: usize,
fps: u32,
) -> Result<FFMpeg>Expand description
Start the FFMPEG rendering
Alias for FFMpeg::start
Examples found in repository?
examples/bouncing-square.rs (line 26)
23fn main() -> ffmpeg::Result<()> {
24 let mut pixels: [Color; PIXEL_COUNT] = [0; PIXEL_COUNT];
25
26 let mut ffmpeg = ffmpeg::start("out.mp4", WIDTH, HEIGHT, FPS)?;
27
28 let mut x = 0;
29 let mut y = 0;
30 let mut dx = 1;
31 let mut dy = 1;
32 let w = 50;
33 let h = 50;
34 for _ in 0..(60 * FPS) {
35 pixels.fill(0);
36 draw_rect(&mut pixels, WIDTH, x, y, w, h, 0xFF00FF00);
37 ffmpeg.send_frame(&pixels)?;
38
39 let new_x = x + dx;
40 if (0..WIDTH as i32 - w).contains(&new_x) {
41 x = new_x;
42 } else {
43 dx *= -1;
44 }
45
46 let new_y = y + dy;
47 if (0..HEIGHT as i32 - h).contains(&new_y) {
48 y = new_y;
49 } else {
50 dy *= -1;
51 }
52 }
53
54 ffmpeg.finalize()?;
55
56 Ok(())
57}