FFmpeg commands that work, run before publishing.

Each page gives the exact command we ran on FFmpeg 9.0.1, what every flag does, the variants people actually need, the pitfalls we hit, and the same edit as one typed KinoPipe tool call for when you would rather not run FFmpeg at all.

Edit

ffmpeg trim video

Trim a video with FFmpeg

Cut a clip with FFmpeg: the frame-accurate command, the fast stream-copy variant and why -c copy can start early. Verified on FFmpeg 9.0.1.

ffmpeg -ss 2.5 -to 7 -i input.mp4 -c:v libx264 -preset veryfast -crf 18 -c:a aac -b:a 128k trimmed.mp4Read the command

ffmpeg crop video

Crop a video with FFmpeg

Crop a video with FFmpeg: the crop filter syntax, centered crops, square and 9:16 windows, and cropdetect to find black bars. Verified on FFmpeg 9.0.1.

ffmpeg -i input.mp4 -vf "crop=640:360:320:180" -c:v libx264 -crf 23 -preset medium -c:a copy cropped.mp4Read the command

ffmpeg speed up video

Speed up or slow down a video with FFmpeg

Change video speed with FFmpeg: setpts for the picture, atempo for the audio, 2x, 0.5x, 4x and chaining below 0.5. Verified on FFmpeg 9.0.1.

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k fast.mp4Read the command

ffmpeg rotate video

Rotate a video with FFmpeg

Rotate a video with FFmpeg: transpose for 90 degrees, two transposes for 180, metadata-only -display_rotation, and autorotate behaviour. Verified on 9.0.1.

ffmpeg -i input.mp4 -vf "transpose=1" -c:v libx264 -crf 23 -preset medium -c:a copy rotated.mp4Read the command

ffmpeg split video into parts

Split a video into parts with FFmpeg

Split a video into equal parts with FFmpeg: segment muxer with stream copy, the segment_time_delta fix, exact cuts with forced keyframes. FFmpeg 9.0.1.

ffmpeg -i input.mp4 -c copy -map 0 -f segment -segment_time 4 -segment_time_delta 0.1 -reset_timestamps 1 part-%03d.mp4Read the command

ffmpeg reverse video

Reverse a video with FFmpeg

Play a video backwards with FFmpeg reverse and areverse, why it eats memory and how to cut first, plus the forward-then-backward boomerang. FFmpeg 9.0.1.

ffmpeg -ss 0 -t 4 -i input.mp4 -vf reverse -af areverse -c:v libx264 -preset veryfast -crf 20 -c:a aac -b:a 128k reversed.mp4Read the command

Audio

ffmpeg extract audio

Extract audio from a video with FFmpeg

Pull the soundtrack out of a video with FFmpeg: MP3 with -q:a 2, AAC copied to .m4a with no re-encode, WAV for editing, Opus. Verified on FFmpeg 9.0.1.

ffmpeg -i input.mp4 -vn -c:a libmp3lame -q:a 2 output.mp3Read the command

ffmpeg remove audio

Remove audio from a video with FFmpeg

Strip the audio from a video with FFmpeg using -an -c:v copy, keep one track of several with -map, replace or mute the sound. Verified on 9.0.1.

ffmpeg -i input.mp4 -an -c:v copy silent.mp4Read the command

ffmpeg normalize audio

Normalize audio loudness with FFmpeg

Normalize audio with FFmpeg loudnorm in one or two passes, the aresample trap that outputs 96 kHz, and plain gain with volume. Measured on FFmpeg 9.0.1.

ffmpeg -i input.mp4 -af "loudnorm=I=-16:TP=-1.5:LRA=11,aresample=48000" -c:v copy -c:a aac -b:a 160k output.mp4Read the command

ffmpeg remove silence

Remove silence from audio with FFmpeg

Cut leading, trailing and internal silence with FFmpeg silenceremove: how stop_duration caps pauses, the threshold that empties a file. FFmpeg 9.0.1.

ffmpeg -i input.mp3 -af "silenceremove=start_periods=1:start_threshold=-50dB:start_silence=0.1:stop_periods=-1:stop_threshold=-50dB:stop_duration=0.5" -c:a libmp3lame -q:a 2 output.mp3Read the command

ffmpeg waveform image

Generate a waveform image with FFmpeg

Render an audio waveform to PNG with FFmpeg showwavespic: size, colours, split channels, solid background, spectrogram alternative. FFmpeg 9.0.1.

ffmpeg -i input.mp3 -filter_complex "showwavespic=s=1280x240:colors=#21B4CE" -frames:v 1 waveform.pngRead the command