Skip to main content

Module encode

Module encode 

Source
Expand description

Turning pictures into packets: H.264 through the operating system, AV1 through the bundled rav1e.

The mirror of crate::decode — one trait, several backends, and a runtime choice that says plainly why it chose nothing when it does.

§Two formats, two rules

EncodingBackendWhy this one
H.264 — the defaultVideoToolbox (macOS, iOS), Media Foundation (Windows), MediaCodec (Android)Universal hardware decode, everywhere a file goes. Patent-pooled, so only ever the OS’s encoder — never x264, never openh264
AV1rav1e, bundledRoyalty-free and pure Rust, so it ships inside every transcode build. Written only when asked for: vtome cannot yet play it back on most machines

§What the files look like

Every H.264 file vtome writes meets the universal baseline in planning/TODO.md §15, because what a file declares decides whether a hardware decoder takes it: High profile at Level 4.1 (8,192 macroblocks a frame and 245,760 a second — 1080p30 or 720p60 — so a bigger or faster picture is scaled down to fit, see fit_level), 8-bit 4:2:0, no B-frames, a keyframe every two seconds exactly so every GOP is closed, and CABAC. AV1 follows the same shape where it applies: 8-bit 4:2:0, no frame reordering, a keyframe every two seconds.

Structs§

EncoderConfig
How to encode.

Enums§

Backend
Which implementation encodes.
Level
The H.264 level a file declares.

Constants§

BACKENDS
Every backend, in the order open tries them.

Traits§

Encoder
Something that turns frames into packets.

Functions§

backends_for
Which backends could encode this, here, in this build, under hardware.
default_encoding
What import writes when not told: H.264, always — the format every hardware decoder plays (§15). None where the OS offers no H.264 encoder vtome may use; AV1 is then written only when asked for, since vtome cannot yet play AV1 back on most machines (§2).
fit_level
The size a picture of width × height at frame_rate is encoded at, under level: unchanged if it fits, otherwise the largest even size of the same shape that does.
is_available
Whether open would find an encoder for encoding under hardware, without opening one.
open
An encoder for this configuration.