The fastest and safest AV1 encoder.
rav1e is an AV1 video encoder. It is designed to eventually cover all use cases, though in its current form it is most suitable for cases where libaom (the reference encoder) is too slow.
- Intra and inter frames
- 64x64 superblocks
- 4x4 to 64x64 RDO-selected square and 2:1/1:2 rectangular blocks
- DC, H, V, Paeth, smooth, and a subset of directional prediction modes
- DCT, (FLIP-)ADST and identity transforms (up to 64x64, 16x16 and 32x32 respectively)
- 8-, 10- and 12-bit depth color
- 4:2:0 (full support), 4:2:2 and 4:4:4 (limited) chroma sampling
- Variable speed settings
- Near real-time encoding at high speed levels
For the foreseeable future, a weekly pre-release of rav1e will be published every Tuesday.
Automated AppVeyor builds can be found here. Click on a build (it is recommended you select a build based on "master"), then click ARTIFACTS to reveal the rav1e.exe download link.
rav1e can optionally use either libaom
(default) or a dav1d
installation to run some extended tests.
Some x86_64
-specific optimizations require a recent version of NASM.
In order to build, test and link to the codec on UNIX, you need Perl, NASM, CMake, Clang and pkg-config. To install this on Ubuntu or Linux Mint, run:
sudo apt install perl nasm cmake clang pkg-config
On Windows, pkg-config is not required. A Perl distribution such as Strawberry Perl, CMake, and a NASM binary in your system PATH are required.
To build release binary in target/release/rav1e
run:
cargo build --release
rav1e provides a C-compatible set of library, header and pkg-config file.
To build and install it you can use cargo-c:
cargo install cargo-c
cargo cinstall --release
Input videos must be in y4m format. The monochrome color format is not supported.
cargo run --release --bin rav1e -- input.y4m -o output.ivf
Encoder output should be compatible with any AV1 decoder compliant with the v1.0.0 specification. You can build compatible aomdec using the following:
mkdir aom_test
cd aom_test
cmake /path/to/aom -DAOM_TARGET_CPU=generic -DCONFIG_AV1_ENCODER=0 -DENABLE_TESTS=0 -DENABLE_DOCS=0 -DCONFIG_LOWBITDEPTH=1
make -j8
./aomdec ../output.ivf -o output.y4m
rav1e has several optional features that can be enabled by passing --features to cargo test. Passing --all-features is discouraged.
- asm - enabled by default. When enabled, assembly is built for the platforms supporting it.
- It requires
nasm
onx86_64
. - It requires
gas
onaarch64
.
- It requires
NOTE: SSE2
is always enabled on x86_64
, neon
is always enabled for aarch64, you may set the environment variable RAV1E_CPU_TARGET
to rust
to disable all the assembly-optimized routines at the runtime.
- Download the AOM Analyzer.
- Download inspect.js and inspect.wasm and save them in the same directory.
- Run the analyzer:
AOMAnalyzer path_to_inspect.js output.ivf
If your .ivf
file is hosted somewhere (and CORS is enabled on your web server) you can use:
https://arewecompressedyet.com/analyzer/?d=https://people.xiph.org/~mbebenita/analyzer/inspect.js&f=path_to_output.ivf
- src/context.rs - High-level functions that write symbols to the bitstream, and maintain context.
- src/ec.rs - Low-level implementation of the entropy coder, which directly writes the bitstream.
- src/lib.rs - The top level library, contains code to write headers, manage buffers, and iterate through each superblock.
- src/partition.rs - Functions and enums to manage partitions (subdivisions of a superblock).
- src/predict.rs - Intra prediction implementations.
- src/quantize.rs - Quantization and dequantization functions for coefficients.
- src/rdo.rs - RDO-related structures and distortion computation functions.
- src/transform/*.rs - Implementations of DCT and ADST transforms.
- src/util.rs - Misc utility code.
- src/bin/rav1e.rs - rav1e command line tool.
- src/bin/rav1erepl.rs - Command line tool for debugging.
rav1e uses the stable version of Rust (the stable toolchain).
To install the toolchain:
rustup install stable
Format code with rustfmt 1.3.0 and above (distributed with Rust 1.37.0 and above) before submitting a PR.
To install rustfmt:
rustup component add rustfmt
then
cargo fmt
The clippy will help catch common mistakes and improve your Rust code.
We recommend you use it before submitting a PR.
To install clippy:
rustup component add clippy
then you can run cargo clippy
in place of cargo check
.
Run unit tests with:
cargo test
Encode-decode integration tests require libaom and libdav1d.
Installation on Ubuntu:
sudo apt install libaom-dev libdav1d-dev
Installation on Fedora:
sudo dnf install libaom-devel libdav1d-devel
Run encode-decode integration tests against libaom with:
cargo test --release --features=decode_test
Run the encode-decode tests against dav1d
with:
cargo test --release --features=decode_test_dav1d
Run regular benchmarks with:
cargo bench --features=bench
Install cargo-fuzz
with cargo install cargo-fuzz
. Running fuzz targets requires nightly Rust, so install that too with rustup install nightly
.
- List the fuzz targets with
cargo fuzz list
. - Run a fuzz target with
cargo +nightly fuzz run <target>
.- Parallel fuzzing:
cargo +nightly fuzz run --jobs <n> <target> -- -workers=<n>
. - Disable memory leak detection (seems to trigger always):
cargo +nightly fuzz run <target> -- -detect_leaks=0
. - Bump the "slow unit" time limit:
cargo +nightly fuzz run <target> -- -report_slow_units=600
. - Make the fuzzer generate long inputs right away (useful because fuzzing uses a ring buffer for data, so when the fuzzer generates big inputs it has a chance to affect different settings individually):
cargo +nightly fuzz run <target> -- -max_len=256 -len_control=0
. - Release configuration (not really recommended because it disables debug assertions and integer overflow assertions):
RUSTFLAGS='-C codegen-units=1' cargo +nightly fuzz run --release <target>
codegen-units=1
fixes rust-fuzz/cargo-fuzz#161.
- Just give me the complete command line:
RUSTFLAGS='-C codegen-units=1' cargo +nightly fuzz run -j10 encode -- -workers=10 -detect_leaks=0 -timeout=600 -report_slow_units=600 -max_len=256 -len_control=0
.
- Parallel fuzzing:
- Run a single artifact with debug output:
RUST_LOG=debug <path/to/fuzz/target/executable> <path/to/artifact>
, for example,RUST_LOG=debug fuzz/target/x86_64-unknown-linux-gnu/debug/encode fuzz/artifacts/encode/crash-2f5672cb76691b989bbd2022a5349939a2d7b952
. - For adding new fuzz targets, see comment at the top of
src/fuzzing.rs
.
Come chat with us on the IRC channel #daala on Freenode! If you don't have IRC set up you can easily connect from your web browser.