💾 Archived View for sebastien-mouchet.fr › blog › en › ffmpeg-cheat-sheet.gmi captured on 2024-03-21 at 15:06:08. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2024-02-05)
-=-=-=-=-=-=-
Posted on January 20, 2024, by SĂ©bastien
Cet article est également disponible en français.
———
This is a highly abridged version of the following blog post:
Audio/video encoding with FFmpeg
———
ffmpeg -i input.wav output.flac
“-i” stands for “input file”.
ffmpeg -i input.wav -c:a libmp3lame -q:a 0 output.mp3
With the LAME MP3 encoder, quality goes from 0 (highest) to 9 (lowest). Using the “quality” parameter instructs LAME to use a variable bitrate.
ffmpeg -i input.wav -c:a libopus -b:a 160k output.opus
“-b:a” stands for “audio bitrate” (you can also use “-ab”). By default, the Opus encoder is in variable bitrate mode (not constant bitrate), so this is a target averate bitrate.
ffmpeg -i input.mp4 -c:v libx264 -crf 24 -c:a libmp3lame -q:a 2 output.mp4
“-c:v” stands for “video codec” (alias to “-vcodec”).
The CRF mode is a “constant quality” mode, as opposed to a “constant bitrate” mode.
Reasonable values for the CRF parameter are between 18 (very high quality) and 28 (medium quality).
ffmpeg -i input.mp4 -c:v libsvtav1 -crf 38 -preset 4 -c:a libopus -b:a 128k output.webm
CRF values for “SVT-AV1” are tuned differently than for x264, but the basic idea is the same: increasing it results in a lower quality, and a smaller file size.
The “preset” option is used to adjust the tradeoff between quality and encoding speed. 0 is be the highest quality, and 13 is be the fastest. Keep it as low as you can afford.
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 40 -b:v 0 -c:a libopus -b:a 128k output.webm