defnotmid

Projects / 02

odecs

Native Odin media codecs and containers. Video, audio and image decoding and encoding with no FFmpeg or other codec library at runtime.

  • Odin
  • MIT
  • no FFmpeg
  • Vulkan Video
  • VideoToolbox
  • Linux · Windows · macOS
Source on GitHub ↗
26 seconds of odecs, music included: ProRes 4444 and VP9 alpha composited live, an 11158×2156 WebP panned across the frame, and the encode and decode numbers. Rendered with onimite, which decodes its clips and encodes its output with odecs.

By the numbers

ProRes 4444 + alpha, 1080p
322 fps
through RGBA, 8 threads (88 fps on one)
per 1080p H.265 frame, Vulkan Video decode
1.00 ms
three in flight, down from 2.36 ms one at a time
native H.264 encode, 1080p, QP 26
144 fps
16 slices on 16 workers; x264 medium does 221
WebP corpus files
131 / 131
RGBA-identical to dwebp

Figures from the odecs docs (codec/movie, codec/gpu, codec/h264, codec/webp READMEs), measured on a Ryzen 9 9900X3D and an RX 9070 XT.

What's in it

  1. 01One API over everything

    codec/media encodes and decodes through the native codecs or the hardware ones, choosing what the machine supports.

  2. 02Hardware when it's there

    Vulkan Video sessions for H.264, H.265 and AV1 on Linux, VideoToolbox H.264 and HEVC decode on macOS, the native codecs as the software path.

  3. 03Movie files in one call

    codec/movie turns RGBA frames and f32 PCM into MP4 and back, with frame-accurate seeking.

  4. 04Your threads, not ours

    Parallel work runs on the caller's Work_Pool. The codecs never create threads of their own.

  5. 05Plain Odin

    The native codecs and containers build for Linux, Windows and macOS with nothing else to install.

  6. 06A player included

    viewer is an SDL3 player for every format odecs reads.

Formats

Video

H.264
encode + decode, progressive 8-bit 4:2:0, encoder checkpoints for editing
H.265
encode + decode, Main, Main 10 and range extensions, alpha layers
ProRes
decode, 422 and 4444/XQ with alpha
VP9
decode, profiles 0–3, alpha streams
AV1
hardware decode through Vulkan Video

Audio

AAC-LC
encode + decode, 1 to 8 channels
Opus
SILK, hybrid, CELT, loss concealment, FEC, DTX, surround
FLAC
4 to 32 bits
MP3
MPEG-1/2/2.5 Layer III

Images

WebP
lossy, lossless, alpha and animation to RGBA8

Containers

MP4 / MOV
read + write
WebM / Matroska
read
Ogg
for Ogg Opus
WAV
WAV, RF64 and RIFX

Some packages are ported from permissively licensed projects (libopus, libwebp, minimp3, PDMP3, gen2brain/h265, oxideav-h265, Kvazaar, OpenH264); their notices are kept beside the code.

Use it

import movie "odecs/codec/movie"

config := movie.default_writer_config(1920, 1080, 30000, 1001) // qp 23, faststart
config.codec = .H264                 // or .H265
config.sample_rate, config.channels = 48000, 2
w: movie.Writer
err := movie.create(&w, "out.mp4", config)   // or create_stream
err = movie.write_audio(&w, pcm)     // any amount, any time
for frame in frames do err = movie.write_frame(&w, frame.rgba, frame.width * 4)
err = movie.finish(&w)
movie.destroy(&w)

The family