Skip to main content

Module engine

Module engine 

Source
Expand description

The compression engine contract and shared types.

Key architectural decision: core is designed around the Engine interface even while there is exactly one engine (media/ffmpeg). This lets us plug in images/PDF/office later without rewriting the skeleton.

Principle: Engine::plan is a pure, testable function (bitrate math); side effects are isolated in Engine::run.

Modules§

media
Media engine v0.1: video + audio via ffmpeg (external process).
plan
The pure half of the media engine: planning an encode (video bitrate under a size target, quality mode, resolution / fps caps, the audio decision, output container, metadata tags) and the small calculations the run loop uses (the size-target ceiling, overshoot corrections). No ffmpeg — this is what builds without the ffmpeg feature (e.g. for iOS).

Structs§

AudioSpec
Audio encoding parameters (absent means drop the track).
CaptureMeta
Capture metadata read from the source’s container tags. iPhone videos keep these as com.apple.quicktime.* keys; others use plain location / make / model / creation_time.
EncodePlan
The encode plan — the result of Engine::plan. Usable for --dry-run.
EncodeSpec
The full encode recipe.
MediaInfo
Source file metadata — the result of Engine::probe.
Outcome
The execution result — the result of Engine::run.
ShrinkOpts
Compression options passed to the engine — the decoded form of the flags.
VideoSpec
Video encoding parameters.

Enums§

EngineError
Engine errors.
Hdr
HDR transfer function of a source video.
SizeGoal
What the user wants in terms of size.

Constants§

MIN_SAVING
A quality-mode re-encode has to save at least this share of the source to be worth it; below that the original is kept. A minutes-long 4K encode for a 1 % saving isn’t a compression — just a generation of quality loss.

Traits§

Engine
The compression engine contract. The one v0.1 implementation is media::MediaEngine.

Functions§

not_worth_it
Whether a result of expected bytes isn’t worth producing for a source of source bytes (saves less than MIN_SAVING). The guard, dry runs and UI previews all ask this, so a preview and the run agree.