YUV4MPEG2 (.y4m) Encoder/Decoder. Format specification.
Simple stream copying:
```rust 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.getwidth(), dec.getheight(), dec.getframerate()) .withcolorspace(dec.getcolorspace().unwrapor(y4m::Colorspace::C420)) .writeheader(&mut outfh) .unwrap(); loop { match dec.readframe() { Ok(frame) => if enc.writeframe(&frame).iserr() { 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:
bash
cargo build --release --example resize
ffmpeg -i in.mkv -f yuv4mpegpipe - | target/release/examples/resize - 640x360 - | mpv -
Library is licensed under MIT.