y4m

Crates.ioy4m
lib.rsy4m
version0.8.0
sourcesrc
created_at2015-11-07 16:04:16.727539
updated_at2023-04-21 11:32:10.292388
descriptionYUV4MPEG2 (.y4m) Encoder/Decoder.
homepagehttps://github.com/image-rs/y4m
repositoryhttps://github.com/image-rs/y4m.git
max_upload_size
id3379
size31,071
Bertie (github:cryspen:bertie)

documentation

https://docs.rs/y4m

README

y4m Build Status crates.io

YUV4MPEG2 (.y4m) Encoder/Decoder. Format specification.

Usage

Simple stream copying:

extern crate y4m;
use std::io;

let mut infh = io::stdin();
let mut outfh = io::stdout();
let mut dec = y4m::decode(&mut infh).unwrap();
let mut enc = y4m::encode(dec.get_width(), dec.get_height(), dec.get_framerate())
    .with_colorspace(dec.get_colorspace())
    .write_header(&mut outfh)
    .unwrap();
loop {
    match dec.read_frame() {
        Ok(frame) => if enc.write_frame(&frame).is_err() { break },
        _ => break,
    }
}

See API documentation for overview of all available methods. See also this example on how to resize input y4m into grayscale y4m of different resolution:

cargo build --release --example resize
ffmpeg -i in.mkv -f yuv4mpegpipe - | target/release/examples/resize - 640x360 - | mpv -

License

Library is licensed under MIT.

Commit count: 100

cargo fmt