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
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
01One API over everything
codec/media encodes and decodes through the native codecs or the hardware ones, choosing what the machine supports.
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.
03Movie files in one call
codec/movie turns RGBA frames and f32 PCM into MP4 and back, with frame-accurate seeking.
04Your threads, not ours
Parallel work runs on the caller's Work_Pool. The codecs never create threads of their own.
05Plain Odin
The native codecs and containers build for Linux, Windows and macOS with nothing else to install.
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)r: movie.Reader
err := movie.open_reader(&r, "in.mov", {preference = .Native}) // or open_reader_stream
// r.video: codec, width, height, frame_count, fps_num/den, duration, rotation,
// color, has_alpha, bit_depth, chroma
// r.audio: codec, present, sample_rate, channels, samples
for {
f, e := movie.next_frame(&r) // sequential playback
if e == .End_Of_Stream do break
// f.rgba (borrowed until the next call), f.pts, f.time, f.index
}odin build viewer -o:speed && ./viewer.bin FILE