Skip to content
Latchkey

ffmpeg -i -c:v: Transcode Video in CI

ffmpeg -i input.mov -c:v libx264 -crf 23 out.mp4 re-encodes a file into a new codec and container in one command.

Transcoding is ffmpeg's core job. In CI you usually convert test or asset media to a web-friendly H.264 MP4; the codec and quality flags are the knobs that matter.

What it does

ffmpeg reads the input named by -i, decodes it, re-encodes the streams with the codecs you choose (-c:v for video, -c:a for audio), and writes the output container inferred from the file extension. Without -c flags it copies or picks defaults per format.

Common usage

Terminal
# transcode to H.264/AAC MP4
ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -c:a aac out.mp4
# just remux (change container, no re-encode) - fast
ffmpeg -i input.mkv -c copy out.mp4
# scale down and re-encode
ffmpeg -i input.mp4 -vf scale=1280:-2 -c:v libx264 -crf 23 small.mp4

Options

FlagWhat it does
-i <file>Input file (can repeat for multiple inputs)
-c:v <codec>Video codec, e.g. libx264, libx265, vp9
-c:a <codec>Audio codec, e.g. aac, libmp3lame, libopus
-c copyStream copy (remux without re-encoding)
-crf <n>Quality for x264/x265 (lower is better, 18-28 typical)
-preset <p>Speed/size tradeoff: ultrafast..veryslow
-y / -nOverwrite without asking / never overwrite

In CI

Pass -y so ffmpeg overwrites an existing output instead of stopping on the interactive "File already exists. Overwrite?" prompt, which hangs a non-interactive job. Add -nostdin if another step might feed ffmpeg stray stdin. -loglevel error keeps the log clean.

Common errors in CI

"ffmpeg: command not found" means ffmpeg is not installed; add apt-get install -y ffmpeg (Debian/Ubuntu) or use a setup action. "Unknown encoder 'libx264'" means this ffmpeg was built without that codec; the distro static build or apt-get install ffmpeg includes it, but some minimal/-free builds omit non-free encoders, so install a full build. "Conversion failed!" with "height not divisible by 2" comes from -vf scale with an odd dimension; use scale=1280:-2 (the -2 keeps the result even).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →