Convert Figma logo to code with AI

xiph logorav1e

The fastest and safest AV1 encoder.

3,679
250
3,679
238

Top Related Projects

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

17,259

HandBrake's main development repository

Quick Overview

rav1e is an AV1 video encoder written in Rust. It aims to provide a fast, safe, and high-quality implementation of the AV1 video codec. The project is part of the Xiph.org Foundation and is designed to be used as both a standalone tool and a library for integration into other applications.

Pros

  • Written in Rust, providing memory safety and thread safety
  • High-performance encoding with multi-threading support
  • Actively maintained and regularly updated
  • Supports a wide range of encoding settings and features

Cons

  • Still in development, may have occasional bugs or instability
  • Limited documentation compared to more established encoders
  • Slower encoding speed compared to some other AV1 encoders
  • Requires Rust knowledge for advanced usage or contributions

Code Examples

  1. Basic encoding example:
use rav1e::*;

let cfg = Config::default();
let mut ctx: Context<u8> = cfg.new_context().unwrap();

let frame = ctx.new_frame();
ctx.send_frame(frame).unwrap();
ctx.flush();

while let Ok(pkt) = ctx.receive_packet() {
    // Process encoded packet
}
  1. Setting encoding parameters:
use rav1e::*;

let mut cfg = Config::default();
cfg.width = 1920;
cfg.height = 1080;
cfg.speed_settings.speed = 6;
cfg.enc.min_key_frame_interval = 48;
cfg.enc.max_key_frame_interval = 240;

let ctx: Context<u8> = cfg.new_context().unwrap();
  1. Using the command-line interface:
use rav1e::*;

let mut cli = Rav1eCmd::parse();
cli.process().unwrap();

Getting Started

To use rav1e in your Rust project, add the following to your Cargo.toml:

[dependencies]
rav1e = "0.6"

Then, in your Rust code:

use rav1e::*;

fn main() {
    let cfg = Config::default();
    let mut ctx: Context<u8> = cfg.new_context().unwrap();
    
    // Add frames and encode
    // ...
}

For command-line usage, install rav1e using Cargo:

cargo install rav1e

Then use it to encode videos:

rav1e input.y4m -o output.ivf

Competitor Comparisons

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

Pros of FFmpeg

  • Comprehensive multimedia framework supporting a wide range of formats and codecs
  • Extensive documentation and large community support
  • Mature project with long-standing development history

Cons of FFmpeg

  • Large codebase can be complex to navigate and contribute to
  • Slower to adopt cutting-edge codecs and features
  • C-based implementation may be less accessible for some developers

Code Comparison

rav1e (Rust):

let mut ctx: Context<u16> = Config::default()
    .with_threads(4)
    .with_encoder_config(EncoderConfig::default())
    .new_context()
    .unwrap();

FFmpeg (C):

AVCodecContext *c = avcodec_alloc_context3(codec);
c->thread_count = 4;
avcodec_open2(c, codec, NULL);

rav1e is a specialized AV1 encoder written in Rust, focusing on speed and safety. FFmpeg is a more comprehensive multimedia framework written in C, supporting various formats and codecs. rav1e may offer better performance for AV1 encoding, while FFmpeg provides broader functionality and format support. The code examples demonstrate the initialization process for each library, highlighting the differences in language and API design.

17,259

HandBrake's main development repository

Pros of HandBrake

  • User-friendly GUI for easy video transcoding
  • Supports a wide range of input formats and codecs
  • Includes presets for various devices and platforms

Cons of HandBrake

  • Less focused on AV1 encoding compared to rav1e
  • May have slower encoding speeds for certain formats
  • Not specifically optimized for low-latency encoding

Code Comparison

HandBrake (C):

static int decodeAudio(hb_work_object_t *w, hb_buffer_t **buf_in,
                       hb_buffer_t **buf_out)
{
    hb_work_private_t *pv = w->private_data;
    hb_buffer_t *in = *buf_in;

rav1e (Rust):

pub fn encode_frame<T: Pixel>(
    &mut self,
    frame: Option<&Frame<T>>,
) -> Result<Option<Packet<T>>, EncoderStatus> {
    let mut frame_data = None;

Both repositories focus on video encoding, but HandBrake offers a more comprehensive solution with a user-friendly interface, while rav1e specializes in AV1 encoding with a focus on performance and low-latency applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

rav1e Actions Status CodeCov

The fastest and safest AV1 encoder.

Table of Content

Overview

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.

Features

  • Intra, inter, and switch frames
  • 64x64 superblocks
  • 4x4 to 64x64 RDO-selected square and rectangular blocks
  • DC, H, V, Paeth, smooth, and all 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, 4:2:2 and 4:4:4 chroma sampling
  • 11 speed settings (0-10, exhaustive to near real-time)
  • Constant quantizer and target bitrate (single- and multi-pass) encoding modes
  • Still picture mode

Documentation

Find the documentation in doc/

Releases

For the foreseeable future, a weekly pre-release of rav1e will be published every Tuesday.

Building

Toolchain: Rust

rav1e currently requires Rust 1.74.0 or later to build.

Dependency: NASM

Some x86_64-specific optimizations require NASM 2.14.02 or newer and are enabled by default. strip will be used if available to remove the local symbols from the asm objects.

The CI is testing against nasm 2.15.05, so bugs for other versions might happen. If you find one please open an issue!

Install nasm

ubuntu 20.04 (nasm 2.14.02)

sudo apt install nasm

ubuntu 18.04 (nasm 2.14.02)

sudo apt install nasm-mozilla
# link nasm into $PATH
sudo ln /usr/lib/nasm-mozilla/bin/nasm /usr/local/bin/

fedora 31, 32 (nasm 2.14.02)

sudo dnf install nasm

windows (nasm 2.15.05)
Have a NASM binary in your system PATH.

$NASM_VERSION="2.15.05" # or newer
$LINK="https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64"
curl --ssl-no-revoke -LO "$LINK/nasm-$NASM_VERSION-win64.zip"
7z e -y "nasm-$NASM_VERSION-win64.zip" -o "C:\nasm"
# set path for the current sessions
set PATH="%PATH%;C:\nasm"

macOS (nasm 2.15.05)

brew install nasm

Release binary

To build release binary in target/release/rav1e run:

cargo build --release

Unstable features

Experimental API and Features can be enabled by using the unstable feature.

cargo build --features <feature>,unstable

Current unstable features

  • Channel API:
cargo build --features channel-api,unstable

Those Features and API are bound to change and evolve, do not rely on them staying the same over releases.

Target-specific builds

The rust compiler can produce a binary that is about 11%-13% faster if it can use avx2, bmi1, bmi2, fma, lzcnt and popcnt in the general code, you may allow it by issuing:

RUSTFLAGS="-C target-cpu=native" cargo build --release
# or
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release

The resulting binary will not work on cpus that do not sport the same set of extensions enabled.

NOTE : You may use rustc --print target-cpus to check if the cpu is supported, if not -C target-cpu=native would be a no-op.

Building the C-API

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

Please refer to the cargo-c installation instructions.

Usage

Compressing video

Input videos must be in y4m format. The monochrome color format is not supported.

cargo run --release --bin rav1e -- input.y4m -o output.ivf

(Find a y4m-file for testing at tests/small_input.y4m or at http://ultravideo.cs.tut.fi/#testsequences)

Decompressing video

Encoder output should be compatible with any AV1 decoder compliant with the v1.0.0 specification. You can decode using dav1d, which is now packaged in over 40 repositories.

dav1d -i output.ivf -o output.y4m

Configuring

rav1e has several optional features that can be enabled by passing --features to cargo. Passing --all-features is discouraged.

Features

Find a full list in feature-table in Cargo.toml

  • asm - enabled by default. When enabled, assembly is built for the platforms supporting it.
    • x86_64: Requires nasm.
    • aarch64
      • Requires gas
      • Alternative: Use clang assembler by setting CC=clang

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.

Contributing

Please read our guide to contributing to rav1e.

Getting in Touch

Come chat with us on the IRC channel #daala on Libera.Chat! You can also use a web client to join with a web browser.