pub struct CodecId(/* private fields */);Expand description
Codec identifier. Wraps the integer value of an AVCodecID enum
variant; comparisons and storage work without ever transmuting back
into the bindgen enum.
§The number is the identity; the name is a rendering of it
raw is what this type is — what FFmpeg passed, what
a store keys on, what equality compares. name and
long_name read libavcodec’s descriptor table for
the word beside that number, so a consumer can cross into a typed
codec vocabulary (mediaframe’s, say) or write a human row without
this crate owning a second table that could come to disagree with
FFmpeg’s. Neither is a key: two builds of FFmpeg agree on the number
long before they agree on every string.
Implementations§
Source§impl CodecId
impl CodecId
Sourcepub const MPEG2VIDEO: Self
pub const MPEG2VIDEO: Self
MPEG-2 Video (ITU-T H.262 / ISO/IEC 13818-2).
Sourcepub const DVB_SUBTITLE: Self
pub const DVB_SUBTITLE: Self
DVB subtitle (bitmap).
Sourcepub const HDMV_PGS_SUBTITLE: Self
pub const HDMV_PGS_SUBTITLE: Self
HDMV / Blu-ray PGS subtitle (bitmap).
Sourcepub const DVD_SUBTITLE: Self
pub const DVD_SUBTITLE: Self
DVD VOBSUB subtitle (bitmap).
Sourcepub const fn from_raw(raw: i32) -> Self
pub const fn from_raw(raw: i32) -> Self
Constructs a CodecId from the raw integer FFmpeg uses for
AVCodecContext::codec_id etc. Use this only when you have a
value that came from FFmpeg or that you know maps to a real
codec; arbitrary integers are still legal but Debug will fall
back to printing the raw value.
Sourcepub fn name(self) -> Option<SmolStr>
pub fn name(self) -> Option<SmolStr>
FFmpeg’s own short name for this codec — "h264", "aac",
"subrip" — or None where this build’s libavcodec has no
descriptor for the id.
An open vocabulary, deliberately. The answer is whatever the
linked libavcodec’s codec_descriptors[] says, not a set this
crate enumerates: a codec FFmpeg learns in its next release names
itself here with no change on this side, which an enum of codecs
could never do. The constants above are the ids this crate has
reason to compare against; they are not the roster of what this
method can answer.
None is a real answer, and it is why the descriptor table is
read rather than avcodec_get_name: that function never fails, and
for an id it cannot place it hands back the string
"unknown_codec" — a sentinel a consumer would store as if it were
a codec’s word. Here an id with no descriptor has no name, said
plainly.
The word is the one FFmpeg’s CLI and its containers use, which is
what makes it the right thing to cross a typed vocabulary with;
raw stays the identity.
Sourcepub fn long_name(self) -> Option<SmolStr>
pub fn long_name(self) -> Option<SmolStr>
FFmpeg’s human description for this codec — "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10" — or None where the build has no
descriptor, or the descriptor carries no description.
A display string and nothing more: it is FFmpeg’s prose, it is not
stable across releases, and nothing should key on it. Use
name to cross vocabularies and raw
to identify.