Rust crate to use video as collection of images.
Go to file
Rafael Caricio aa1831bed3
Bump vesion 0.1.1
2022-04-25 13:10:16 +02:00
examples Initialize gstreamer only once 2021-03-13 18:07:45 +01:00
resources Initialize gstreamer only once 2021-03-13 18:07:45 +01:00
src Implement Error for error types (#1) 2022-04-20 23:45:10 +02:00
.gitignore Initialize gstreamer only once 2021-03-13 18:07:45 +01:00
Cargo.toml Bump vesion 0.1.1 2022-04-25 13:10:16 +02:00
README.md Use std file not found error 2021-03-13 18:14:12 +01:00

README.md

vid2img - Video to Image

vid2img is a Rust crate that allows the use of a video file as a collection of frame images. This crate exposes a FileSource type that accepts a video file path and the desired size of the frames, then you can convert the instance into a iterator (.into_iter()). On every iteration you will receive a video frame data encoded as PNG.

use std::path::Path;
use vid2img::FileSource;

fn main() {
    let file_path = Path::new("video.mp4");

    let frame_source = FileSource::new(file_path, (200, 200)).unwrap();
    for frame in frame_source.into_iter() {
        if let Ok(Some(png_img_data)) = frame {
            // do something with the image data here ...
        }
    }
}

We use GStreamer for processing the video and capturing the frames. We make use of the official Rust wrapper to the GStreamer API.

Installation

As we use GStreamer, the installation steps for the GStreamer-rs crate must be followed.

We make use of the following GStreamer plugins: uridecodebin, videoconvert, videoscale, capsfilter, pngenc, appsrc.

Usage

To use this library, add the following dependency to Cargo.toml:

[dependencies]
vid2img = "0.1.0"