6 releases

0.0.6 Jun 18, 2025
0.0.5 Aug 2, 2024
0.0.4 Aug 1, 2023
0.0.3 Jul 26, 2023
0.0.1 Apr 28, 2023

#120 in Unix APIs

Download history 393/week @ 2025-06-27 373/week @ 2025-07-04 291/week @ 2025-07-11 278/week @ 2025-07-18 322/week @ 2025-07-25 357/week @ 2025-08-01 593/week @ 2025-08-08 632/week @ 2025-08-15 2901/week @ 2025-08-22 4462/week @ 2025-08-29 4111/week @ 2025-09-05 4583/week @ 2025-09-12 4684/week @ 2025-09-19 4705/week @ 2025-09-26 5929/week @ 2025-10-03 6176/week @ 2025-10-10

22,019 downloads per month
Used in 42 crates (via re_video)

BSD-3-Clause

3MB
36K SLoC

Cros-codecs

crates.io docs.rs

A lightweight, simple, low-dependency, and hopefully safe crate for hardware-accelerated video decoding and encoding on Linux.

It is developed for use in ChromeOS (particularly crosvm), but has no dependency to ChromeOS and should be usable anywhere.

Current features

  • Simple decoder API,
  • VAAPI decoder support (using cros-libva) for H.264, H.265, VP8, VP9 and AV1,
  • VAAPI encoder support for H.264, VP9 and AV1,
  • Stateful V4L2 encoder support.

Planned features

  • Stateful V4L2 decoder support,
  • Stateless V4L2 decoder support,
  • Support for more encoder codecs,
  • C API to be used in non-Rust projects.

Non-goals

  • Support for systems other than Linux.

Example programs

The ccdec example program can decode an encoded stream and write the decoded frames to a file. As such it can be used for testing purposes.

$ cargo build --examples
$ ./target/debug/examples/ccdec --help
Usage: ccdec <input> [--output <output>] --input-format <input-format> [--output-format <output-format>] [--compute-md5 <compute-md5>]

Simple player using cros-codecs

Positional Arguments:
  input             input file

Options:
  --output          output file to write the decoded frames to
  --input-format    input format to decode from.
  --output-format   pixel format to decode into. Default: i420
  --compute-md5     whether to display the MD5 of the decoded stream, and at
                    which granularity (stream or frame)
  --help            display usage information

Testing

Fluster can be used for testing, using the ccdec example program described above. This branch contains support for cros-codecs testing. Just make sure the ccdec binary is in your PATH, and run Fluster using one of the ccdec decoders, e.g.

python fluster.py run -d ccdec-H.264 -ts JVT-AVC_V1

Credits

The majority of the code in the initial commit has been written by Daniel Almeida as a VAAPI backend for crosvm, before being split into this crate.

Dependencies

~0–13MB
~138K SLoC