The basics of handling volume, sample rate, and channels with -af, and a checklist (color range, SAR, pixel format, and so on) to run through after building a filter chain.
Audio follows the same decode → filter → encode flow as video. You write a filter chain with -af (or -filter:a), and the comma and colon rules are the same (Filtergraph syntax). You won't use it as often as video filters, but a few of these are handy to know in practice.
The options and allowed ranges of each filter (for example, the ratio range of atempo) can differ by FFmpeg version, so check with ffmpeg -h filter=<name>.
ffmpeg -i input.mp4 -c:v copy \
-af "volume=3dB,aresample=48000,aformat=channel_layouts=stereo" \
-c:a aac -b:a 160k output.mp4volume=3dB just boosts every sound equally; it doesn't match a target loudness. To match broadcast or streaming loudness standards, see LUFS and loudnorm. If you boost too far, peaks can overflow and cause distortion (clipping).-ac 2 works too, but there are many accounts of the center channel (dialogue) sounding quiet. You can set the downmix coefficients yourself with the pan filter. Always listen to check whether the dialogue gets quieter before deciding.setpts).When you chain several filters, it's hard to tell by eye alone what state the resulting file is in. Get in the habit of checking the items below with ffprobe and playback. It gathers the common mistakes covered in this chapter in one place.
The principles of color tags and color range are in Chapter 1 (color gamut) and Chapter 14 (why colors look washed out), and measurement pitfalls are in Chapter 11 (Measurement pitfalls).
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,pix_fmt,width,height,sample_aspect_ratio,display_aspect_ratio,r_frame_rate,field_order,color_range,color_space,color_primaries,color_transfer \
-of default=nw=1 output.mp4If the result looks wrong, remove filters starting from the last one, one at a time, and render the same section (10 seconds) again. You'll quickly narrow down which filter caused the problem. You can also run with -f null - output to quickly check just the speed and errors. When you combine filters with a hardware encoder, frames may have to move back and forth between GPU memory and CPU memory (Hardware encoders), so check whether there is a hardware version of the filter under a different name.
A filter that changes the audio sampling rate.
A filter that multiplies the audio volume or adjusts it in dB. Different from loudnorm, which matches a target loudness.
A filter that changes audio playback speed while keeping pitch.
A name for a frame's color representation, chroma subsampling, and bit depth. Example: yuv420p.
You want to match broadcast loudness (LUFS). Why isn't volume=3dB enough?
A video built with several chained filters won't play on some devices. What should you check first?