pub enum VideoCodec {
H264,
OpenH264,
H265,
Kvazaar,
Vp8,
Vp9,
Av1,
Svtav1,
Mpeg4,
}Expand description
Which software encoder to open. Whatever’s picked, SwEncoder::new
fails with SwEncoderError::CodecNotFound (not a panic) if the
linked ffmpeg build doesn’t actually have it — this crate never
vendors any of these, it’s whatever the local ffmpeg install was built
with (check with ffmpeg -encoders).
GPL-licensed encoders need an ffmpeg build compiled with
--enable-gpl (separate from — and unlike — FFmpeg’s own native
h264/hevc decoders, which SwDecoder already uses and which
carry no such requirement; GPL only enters the picture on the encode
side, through these specific libraries): VideoCodec::H264 and
VideoCodec::H265 are GPL. Every other variant here is a
permissively-licensed (BSD/similar) alternative that needs no special
build flag beyond being enabled at all.
Variants§
H264
libx264 — H.264. GPL.
OpenH264
libopenh264 — H.264, Cisco’s BSD-2-Clause encoder (Cisco covers
H.264 patent royalties for binary redistributions of it). The
non-GPL alternative to VideoCodec::H264.
H265
libx265 — H.265/HEVC. GPL.
Kvazaar
libkvazaar — H.265/HEVC, BSD-2-Clause. The non-GPL alternative
to VideoCodec::H265.
Vp8
libvpx — VP8, BSD-3-Clause.
Vp9
libvpx-vp9 — VP9, BSD-3-Clause (same libvpx project as
VideoCodec::Vp8, different encoder name).
Av1
libaom-av1 — AV1’s reference encoder, BSD-2-Clause. Most
broadly compatible AV1 output, but much slower than
VideoCodec::Svtav1 — prefer that one unless you specifically
need libaom’s own encoding behavior.
Svtav1
libsvtav1 — AV1 via Intel’s SVT-AV1, BSD-2-Clause-Patent. Far
faster than VideoCodec::Av1 (libaom-av1) at a given quality
target — the practical default for real-time AV1 encoding.
Mpeg4
mpeg4 — MPEG-4 Part 2, and the only encoder here that is FFmpeg’s
own rather than a library it was linked against.
Which is the whole reason it is offered. Every variant above needs its library to have been enabled at build time, and an FFmpeg with none of them cannot encode video at all through this element. This one is in every build there is.
It is also the only always-present encoder that will emit B-frames
(see SwEncoderOptions::max_b_frames) — libopenh264 emits none
whatever it is asked for, and the H.264 encoders that would are the
GPL ones. That makes it what a test reaches for when what it is
testing is reordering.
Not a codec to choose for output anyone has to play: it predates H.264 and compresses far worse at the same quality.
Trait Implementations§
Source§impl Clone for VideoCodec
impl Clone for VideoCodec
Source§fn clone(&self) -> VideoCodec
fn clone(&self) -> VideoCodec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more