14 releases (7 breaking)

Uses old Rust 2015

0.8.0 Apr 21, 2023
0.7.0 Aug 21, 2020
0.6.1 Jul 23, 2020
0.5.0 Nov 30, 2019
0.1.1 Nov 7, 2015

#886 in Parser implementations

Download history 2316/week @ 2024-09-17 2375/week @ 2024-09-24 2720/week @ 2024-10-01 2363/week @ 2024-10-08 2386/week @ 2024-10-15 1953/week @ 2024-10-22 2034/week @ 2024-10-29 2464/week @ 2024-11-05 2114/week @ 2024-11-12 2141/week @ 2024-11-19 2122/week @ 2024-11-26 2846/week @ 2024-12-03 2201/week @ 2024-12-10 1532/week @ 2024-12-17 1241/week @ 2024-12-24 1641/week @ 2024-12-31

7,067 downloads per month
Used in 16 crates (12 directly)

MIT license

25KB
525 lines

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.

No runtime deps