Rust: How to slideshow captured images

Hi rust community! Well I am using rscam crate for capturing images.
It works well, here is the code;

use rscam::{Camera, Config};
use std::fs;
use std::io::Write;

fn main() {
let mut camera = rscam::new("/dev/video2").unwrap();

camera.start(&rscam::Config {
    interval: (1, 30),      // 30 fps.
    resolution: (1280, 720),
    format: b"MJPG",
    ..Default::default()
}).unwrap();

for i in 0..100 {
    let frame = camera.capture().unwrap();
    let mut file = fs::File::create(&format!("frame-{}.jpg", i)).unwrap();
    file.write_all(&frame[..]).unwrap();
 }
}

this capture images and saves them in my directory. Now i have a question.
Is there any crate which can help me collect all this images into a slideshow,or how can i make a 'video' with my capture images? (I was thinking to make a gif at first but maybe this is not the correct way).. any help ?

You can use imagemagick to concatenate images to a gif (link) or ffmpeg to concatenate into a video (link).

1 Like

didn't help me at all...

I don't know of any crates that can do it, but you can run a command to execute those external programs. Perhaps those programs are also available as crates, but you'll have to investigate how to use them yourself.

1 Like

I am searching in lib.rs/crates

Can you elaborate?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.