https://github.com/image-rs/y4m
YUV4MPEG2 (.y4m) Encoder/Decoder
https://github.com/image-rs/y4m
Last synced: 3 months ago
JSON representation
YUV4MPEG2 (.y4m) Encoder/Decoder
- Host: GitHub
- URL: https://github.com/image-rs/y4m
- Owner: image-rs
- License: mit
- Created: 2015-11-06T20:52:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-31T05:24:00.000Z (over 1 year ago)
- Last Synced: 2024-03-25T20:23:10.941Z (over 1 year ago)
- Language: Rust
- Homepage: https://docs.rs/y4m
- Size: 63.5 KB
- Stars: 33
- Watchers: 55
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# y4m [](https://github.com/image-rs/y4m/actions?query=branch%3Amaster) [](https://crates.io/crates/y4m)
YUV4MPEG2 (.y4m) Encoder/Decoder. [Format specification](https://wiki.multimedia.cx/index.php?title=YUV4MPEG2).
## Usage
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.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](https://docs.rs/y4m) for overview of all available methods. See also [this example](examples/resize.rs) 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 -
```## License
Library is licensed under [MIT](LICENSE).