Skip to main content

CodecId

Struct CodecId 

Source
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

Source

pub const NONE: Self

AV_CODEC_ID_NONE — sentinel for “no codec.”

Source

pub const H264: Self

H.264 / AVC (ITU-T H.264 / ISO/IEC 14496-10).

Source

pub const HEVC: Self

H.265 / HEVC (ITU-T H.265 / ISO/IEC 23008-2).

Source

pub const AV1: Self

AV1 (Alliance for Open Media).

Source

pub const VP9: Self

VP9 (Google).

Source

pub const VP8: Self

VP8 (Google).

Source

pub const MPEG2VIDEO: Self

MPEG-2 Video (ITU-T H.262 / ISO/IEC 13818-2).

Source

pub const MPEG4: Self

MPEG-4 Part 2 Visual (ISO/IEC 14496-2).

Source

pub const PRORES: Self

Apple ProRes.

Source

pub const DNXHD: Self

Avid DNxHD / DNxHR (SMPTE VC-3).

Source

pub const FFV1: Self

FFV1 — lossless intra-frame.

Source

pub const JPEG2000: Self

JPEG 2000.

Source

pub const MJPEG: Self

MJPEG.

Source

pub const VC1: Self

VC-1 (SMPTE 421M, Microsoft Windows Media Video 9).

Source

pub const VVC: Self

VVC / H.266 (ITU-T H.266).

Source

pub const AAC: Self

AAC (ISO/IEC 14496-3).

Source

pub const MP3: Self

MP3 (MPEG-1/2 Audio Layer III).

Source

pub const OPUS: Self

Opus (RFC 6716).

Source

pub const FLAC: Self

FLAC — Free Lossless Audio Codec.

Source

pub const AC3: Self

AC-3 (ATSC A/52, Dolby Digital).

Source

pub const EAC3: Self

E-AC-3 (Dolby Digital Plus).

Source

pub const ALAC: Self

Apple Lossless Audio Codec.

Source

pub const DTS: Self

DTS / DTS-HD.

Source

pub const VORBIS: Self

Vorbis.

Source

pub const PCM_S16LE: Self

PCM signed 16-bit little-endian.

Source

pub const PCM_S16BE: Self

PCM signed 16-bit big-endian.

Source

pub const PCM_S24LE: Self

PCM signed 24-bit little-endian.

Source

pub const PCM_S32LE: Self

PCM signed 32-bit little-endian.

Source

pub const PCM_F32LE: Self

PCM 32-bit float little-endian.

Source

pub const PCM_F64LE: Self

PCM 64-bit float little-endian.

Source

pub const SUBRIP: Self

SubRip (.srt).

Source

pub const ASS: Self

Advanced SubStation Alpha (.ass / .ssa).

Source

pub const WEBVTT: Self

WebVTT (.vtt).

Source

pub const MOV_TEXT: Self

3GPP Timed Text / MOV text track.

Source

pub const DVB_SUBTITLE: Self

DVB subtitle (bitmap).

Source

pub const HDMV_PGS_SUBTITLE: Self

HDMV / Blu-ray PGS subtitle (bitmap).

Source

pub const DVD_SUBTITLE: Self

DVD VOBSUB subtitle (bitmap).

Source

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.

Source

pub const fn raw(self) -> i32

Returns the underlying integer.

Source

pub fn name(self) -> Option<Utf8Bytes>

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.

Source

pub fn long_name(self) -> Option<Utf8Bytes>

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.

Trait Implementations§

Source§

impl Clone for CodecId

Source§

fn clone(&self) -> CodecId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CodecId

Source§

impl Debug for CodecId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CodecId

Source§

impl Hash for CodecId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for CodecId

Source§

fn eq(&self, other: &CodecId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CodecId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more