1# Cros-codecs 2 3[<img alt="crates.io" src="https://img.shields.io/crates/v/cros-codecs">](https://crates.io/crates/cros-codecs) 4[<img alt="docs.rs" src="https://img.shields.io/docsrs/cros-codecs">](https://docs.rs/cros-codecs/latest/cros_codecs/) 5 6A lightweight, simple, low-dependency, and hopefully safe crate for 7hardware-accelerated video decoding and encoding on Linux. 8 9It is developed for use in ChromeOS (particularly 10[crosvm](https://github.com/google/crosvm)), but has no dependency to ChromeOS 11and should be usable anywhere. 12 13## Current features 14 15- Simple decoder API, 16- VAAPI decoder support (using 17 [cros-libva](https://github.com/chromeos/cros-libva)) for H.264, H.265, VP8, 18 VP9 and AV1, 19- VAAPI encoder support for H.264, VP9 and AV1, 20- Stateful V4L2 encoder support. 21 22## Planned features 23 24- Stateful V4L2 decoder support, 25- Stateless V4L2 decoder support, 26- Support for more encoder codecs, 27- C API to be used in non-Rust projects. 28 29## Non-goals 30 31- Support for systems other than Linux. 32 33## Example programs 34 35The `ccdec` example program can decode an encoded stream and write the decoded 36frames to a file. As such it can be used for testing purposes. 37 38```shell 39$ cargo build --examples 40$ ./target/debug/examples/ccdec --help 41Usage: ccdec <input> [--output <output>] --input-format <input-format> [--output-format <output-format>] [--compute-md5 <compute-md5>] 42 43Simple player using cros-codecs 44 45Positional Arguments: 46 input input file 47 48Options: 49 --output output file to write the decoded frames to 50 --input-format input format to decode from. 51 --output-format pixel format to decode into. Default: i420 52 --compute-md5 whether to display the MD5 of the decoded stream, and at 53 which granularity (stream or frame) 54 --help display usage information 55``` 56 57## Testing 58 59Fluster can be used for testing, using the `ccdec` example program described 60above. [This branch](https://github.com/Gnurou/fluster/tree/cros-codecs) 61contains support for cros-codecs testing. Just make sure the `ccdec` binary is 62in your `PATH`, and run Fluster using one of the `ccdec` decoders, e.g. 63 64```shell 65python fluster.py run -d ccdec-H.264 -ts JVT-AVC_V1 66``` 67 68## Credits 69 70The majority of the code in the initial commit has been written by Daniel 71Almeida as a VAAPI backend for crosvm, before being split into this crate. 72