Skip to main content

Module codec

Module codec 

Source
Available on crate features alloc or std only.
Expand description

Stream-descriptor codec/format/layout vocabulary for video, audio, and subtitle tracks. Requires the alloc feature (std includes it) for the Other(SmolStr) escape arms. Stream-descriptor codec vocabulary for video, audio, subtitle, data, and attachment tracks.

Generated from xtask/vendor/ffmpeg-codecs.txt (FFmpeg n9.0 libavcodec/codec_desc.c) by cargo xtask gen-codec — except [AttachmentCodec], whose roster comes from a different FFmpeg source; see its own doc comment for why. Every codec FFmpeg knows under media types video / audio / subtitle / data has a named variant here; the Other(SmolStr) arm remains a lossless escape for codecs added in a future FFmpeg release before this file is regenerated (or, for AttachmentCodec, before ATTACHMENT_CODECS is re-derived by hand).

Regenerate in two steps:

  1. cargo xtask sync — refreshes the vendored table.
  2. cargo xtask gen-codec — regenerates this file from it.

cargo xtask check verifies every named variant’s canonical string exists in the vendored table (or, for AttachmentCodec, in ATTACHMENT_CODECS) — CI gate against drift.

Derive threshold. Unwrap / TryUnwrap generate three methods per variant, so an enum in the hundreds pays that in compile time for one reachable payload arm. [SubtitleCodec] (27), [DataCodec] (11), and [AttachmentCodec] (3) are small enough to carry the pair; [VideoCodec] (279) and [AudioCodec] (222) do not. The line is variant count, not principle — reach for Other(_) on the large two with a match or IsVariant’s is_other.

Enums§

AttachmentCodec
Attachment codec family — the FFmpeg codec ids libavformat/matroskadec.c’s mkv_mime_tags table assigns to an AVMEDIA_TYPE_ATTACHMENT stream (ATTACHMENT_CODECS; see its doc comment for the full census — libavcodec/codec_desc.c has no AVMEDIA_TYPE_ATTACHMENT media type to enumerate here the way DataCodec and the other vendored enums are).
AudioCodec
Audio codec family — every codec FFmpeg n9.0 knows under media type audio.
DataCodec
Data codec family — every codec FFmpeg n9.0 knows under media type data.
SubtitleCodec
Subtitle codec family — every codec FFmpeg n9.0 knows under media type subtitle.
VideoCodec
Video codec family — every codec FFmpeg n9.0 knows under media type video.