Encoder Behavior by Platform
This page documents Cosmos encoder selection, ffmpeg resolution order, and known platform caveats.
Current encoder preference policy
- macOS:
h264_videotoolbox->libx264 - Linux:
h264_nvenc->h264_qsv->h264_vaapi->libx264 - Windows:
h264_nvenc->h264_qsv->h264_amf->libx264
Runtime fallback behavior
When Cosmos auto-selects hardware encoders (for example in cosmos optimize run --mode auto),
it now performs a runtime viability probe against the selected input and expected output settings.
If the probe fails, Cosmos falls back to libx264 and records the attempted hardware path in provenance.
If an operator explicitly forces --encoder, Cosmos treats that choice as authoritative and surfaces
ffmpeg failure directly.
ffmpeg binary resolution order
Cosmos resolves ffmpeg in this order:
COSMOS_FFMPEGenvironment variable (explicit override)~/.local/share/cosmos/bin/ffmpeg(Cosmos-managed install)- system PATH (
ffmpeg)
The same order applies to ffprobe via COSMOS_FFPROBE.
Linux + NVIDIA bootstrap (POL-464)
Problem
Stock Ubuntu/Debian ffmpeg packages often lack NVENC support, causing software fallback.
Cosmos behavior
On Linux runs, Cosmos checks:
- whether NVIDIA appears present (
nvidia-smior/proc/driver/nvidia/version) - whether the resolved ffmpeg binary supports
h264_nvenc
If GPUs are present but NVENC is missing, Cosmos can offer a scoped ffmpeg bootstrap
into ~/.local/share/cosmos/bin/.
Suppressing checks/prompts
--skip-ffmpeg-checkskips bootstrap checks--yesprevents interactive promptingCOSMOS_FFMPEG=/path/to/ffmpegforces a known binary
macOS notes
h264_videotoolboxmay reject very large inputs (for example 8K).- Use
--prefer-hevc-hwto tryhevc_videotoolboxfirst where appropriate. - Provenance captures attempted/used encoder values for auditability.
Windows notes
Windows support follows the same fallback model, but wider hardware matrix validation is tracked as follow-on work (see POL-173).
Maintenance guidance
Update this page whenever encoder policy, probe behavior, or fallback semantics change.