rust_h264 0.2.0

Pure Rust H.264/AVC video decoder
Documentation
  • Coverage
  • 28.95%
    11 out of 38 items documented0 out of 9 items with examples
  • Size
  • Source code size: 747.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 14.36 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 31s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • roticv/rust_h264
    7 5 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • roticv

rust_h264

While working on rust_media, it was found that there isn't any sufficiently good open source h264 decoder. There is openH264, but it is limited to baseline h264. ffmpeg has its own h264 decoder but it isn't split out as a library.

Hence, the idea is to attempt to create an open source h264 decoder. Yes, most devices have hardware h264 decoder, but if we want to be truly portable, then software implementation of h264 decoder is needed.

Design

  • Input: Annex B bytestream format (start code delimited 00 00 00 01 / 00 00 01). AVCC (length-prefixed) format is not supported — callers must convert to Annex B before feeding data to the decoder.
  • Streaming: The decoder exposes a streaming API. NAL units are fed incrementally and decoded frames are emitted as they become available.
  • Performance: The decoder aims to be fast, with performance relative to ffmpeg's software H.264 decoder as the target benchmark.

Tools

Player

Decode and display an H.264 bitstream in a window:

cargo run --example play -- input.h264 [--fps 30] [--loop]
  • --fps N — set playback frame rate (default: 30)
  • --loop — loop playback continuously
  • Press Escape to quit

Dump frames

Decode an H.264 bitstream to raw YUV420 output:

cargo run --example dump_frames -- input.h264 [output.yuv]

Frames are written in display order (sorted by POC).

License

Licensed under either of

at your option.