Expand description
Converts NAL packets to YUV images.
§Examples
Basic Decoder use looks as follows. In practice, you might get your h264
bitstream from reading a file or network source.
use openh264::decoder::Decoder;
use openh264::nal_units;
let h264_in = include_bytes!("../tests/data/multi_512x512.h264");
let mut decoder = Decoder::new()?;
for packet in nal_units(h264_in) {
// If everything goes well this should yield a `DecodedYUV`.
// It can also be `Err()` if the bitstream had errors, or
// `Ok(None)` if no pictures were available (yet).
let Ok(Some(yuv)) = decoder.decode(packet) else { continue };
}Once you have your yuv, which should be of type DecodedYUV, you can proceed to converting it to RGB:
use openh264::formats::YUVSource;
let rgb_len = yuv.rgb8_len();
let mut rgb_raw = vec![0; rgb_len];
yuv.write_rgb8(&mut rgb_raw);Structs§
- Decode
Options - Configuration for the current decode operation.
- DecodedYUV
- Frame returned by the
Decoderand provides safe data access. - Decoder
- An OpenH264 decoder.
- Decoder
Config - Configuration for the
Decoder. - Decoder
RawAPI - Convenience wrapper with guaranteed function pointers for easy access.
Enums§
- Flush
- How the decoder should handle flushing.