Getting started

Build nanocodec from source, then code and decode a first clip on the command line. The other pages cover the command line, the C API, the Rust API, the browser module and the presets.

Build

You need Rust 1.90 or later (rustup) and git. The workspace builds on stable Rust; SIMD kernels are chosen at run time on each machine.

git clone https://github.com/cribbinsb/nanocodec.git
cd nanocodec
cargo build --release -p nanocodec-cli          # the command line: target/release/nanocodec
cargo build --release -p nanocodec-capi         # the C library: target/release/libnanocodec.{a,so}
TargetHowKernels
x86_64cargo build --releaseAVX2 and AVX-512 where the CPU has them, else scalar
aarch64cargo build --release on the device (tested on a Jetson Orin Nano), or --target aarch64-unknown-linux-gnu with a cross linkerNEON
wasm32rustup target add wasm32-unknown-unknown, then tools/web/build.sh (needs wasm-bindgen-cli 0.2.105); see Browser SIMD128 (required), relaxed SIMD where available

First encode and decode

The encoder reads raw 8-bit 4:2:0 frames (I420 by default). Any raw clip works; this makes a 5-second test clip with ffmpeg:

ffmpeg -f lavfi -i testsrc2=size=640x360:rate=30 -frames:v 150 -pix_fmt yuv420p in.yuv

Encode it to AV1 at 300 kbps with the real-time rate control, keeping the encoder's reconstruction:

nanocodec encode --codec av1 --input in.yuv --width 640 --height 360 --fps 30 --frames 150 \
  --bitrate 300 --output out.ivf --recon recon.yuv

Decode it with our decoder. Its output is the same frames as the reconstruction, byte for byte:

nanocodec decode --codec av1 --input out.ivf --output decoded.yuv
cmp recon.yuv decoded.yuv

The streams are standard: AV1, VP9 and AV2 are written as IVF files, H.264, HEVC and VVC as Annex-B elementary streams, which other players and decoders read too. FFmpeg (and so ffplay) reads the H.264, HEVC, VVC, AV1 and VP9 streams (ffplay out.ivf, ffmpeg -i out.264), not AV2: use AVM's avmdec or ours. AV2 is not a finished standard: it is a draft, and we track its reference software AVM at v1.0.0, so its syntax may still change.

Next