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 Convert
ffmpeg resize video
Resize a video with FFmpeg
Scale a video with FFmpeg: keep the aspect ratio with scale=1280:-2, fit into a box with padding, or crop to 9:16. Every command verified on FFmpeg 9.0.1.
ffmpeg -i input.mp4 -vf "scale=1280:-2" -c:v libx264 -crf 23 -preset medium -c:a copy output.mp4Read the command ffmpeg mov to mp4
Convert MOV to MP4 with FFmpeg
Turn a .mov into an MP4 with FFmpeg: remux in a second when it is already H.264, re-encode ProRes or HEVC, avoid the 4:2:2 trap. Verified on 9.0.1.
ffmpeg -i input.mov -c:v libx264 -crf 23 -preset medium -pix_fmt yuv420p -c:a aac -b:a 160k -movflags +faststart output.mp4Read the command ffmpeg 9:16 vertical video
Make a video vertical (9:16) with FFmpeg
Make a 16:9 video 1080x1920 with FFmpeg: blurred background, black bars or centre crop, plus the encoder flags Reels and TikTok expect. Verified on 9.0.1.
ffmpeg -i input.mp4 -filter_complex "[0:v]split[bg][fg];[bg]scale=1080:1920:force_original_aspect_ratio=increase,crop=1080:1920,boxblur=20:10[bgb];[fg]scale=1080:-2[fgs];[bgb][fgs]overlay=(W-w)/2:(H-h)/2" -c:v libx264 -crf 23 -preset medium -c:a copy vertical.mp4Read the command ffmpeg remove metadata
Remove metadata from a video with FFmpeg
Strip title, comments, GPS and chapters from a video with FFmpeg -map_metadata -1 and stream copy, and what survives (rotation, encoder tag). FFmpeg 9.0.1.
ffmpeg -i input.mp4 -map 0:v -map 0:a -map_metadata -1 -map_chapters -1 -c copy output.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 GIF and images
ffmpeg video to gif
Convert a video to GIF with FFmpeg
Make a GIF from a video with FFmpeg in one command with a generated palette, plus smaller variants (lower fps, fewer colors, dithering). Verified on 9.0.1.
ffmpeg -ss 2 -t 4 -i input.mp4 -filter_complex "fps=15,scale=640:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gifRead the command ffmpeg extract frame
Extract a thumbnail from a video with FFmpeg
Grab a frame from a video with FFmpeg: a JPEG at a timestamp with -ss and -frames:v 1, a scaled version, contact sheet and WebP. Verified on 9.0.1.
ffmpeg -ss 3.5 -i input.mp4 -frames:v 1 -q:v 2 thumb.jpgRead the command ffmpeg image to video
Turn an image into a video with FFmpeg
Image to video with FFmpeg: a still of a set length, a silent audio track, a slideshow from numbered images and a zoompan Ken Burns move. FFmpeg 9.0.1.
ffmpeg -loop 1 -framerate 30 -i image.png -t 10 -c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p output.mp4Read the command Subtitles and overlays
ffmpeg burn subtitles
Add subtitles to a video with FFmpeg
Burn an SRT into a video with the FFmpeg subtitles filter, style it with force_style, or add a soft mov_text track with -c copy. Verified on 9.0.1.
ffmpeg -i input.mp4 -vf "subtitles=captions.srt" -c:v libx264 -crf 23 -preset medium -c:a copy subtitled.mp4Read the command ffmpeg watermark
Add a watermark to a video with FFmpeg
Watermark a video with FFmpeg: overlay a scaled PNG in any corner, set opacity with colorchannelmixer, time-limit it, or draw text. Verified on 9.0.1.
ffmpeg -i input.mp4 -i logo.png -filter_complex "[1:v]scale=240:-1[wm];[0:v][wm]overlay=W-w-24:H-h-24" -c:v libx264 -crf 23 -preset medium -c:a copy watermarked.mp4Read the command Compose
ffmpeg concat videos
Merge videos with FFmpeg
Join clips with FFmpeg: the concat demuxer with -c copy, the concat filter when codecs or sizes differ, and an xfade crossfade. Verified on 9.0.1.
ffmpeg -f concat -safe 0 -i list.txt -c copy merged.mp4Read the command ffmpeg picture in picture
Picture-in-picture with FFmpeg overlay
Overlay one video on another with FFmpeg: corner placement, a border, choosing or mixing the audio, showing the inset for a time range. FFmpeg 9.0.1.
ffmpeg -i main.mp4 -i pip.mp4 -filter_complex "[1:v]scale=360:-2[pip];[0:v][pip]overlay=W-w-24:H-h-24[out]" -map "[out]" -map 0:a -c:v libx264 -preset veryfast -crf 20 -c:a copy output.mp4Read the command Analyze
ffmpeg silencedetect
Detect silence with FFmpeg
Find silent sections with FFmpeg silencedetect: threshold and duration settings, reading the timestamps, writing them to a file. Verified on FFmpeg 9.0.1.
ffmpeg -i input.mp4 -af "silencedetect=noise=-30dB:d=0.5" -f null -Read the command ffmpeg scene detection
Detect scene changes with FFmpeg
Find scene cuts with FFmpeg: select with the scene score, the scdet filter, one thumbnail per scene, timestamps to a file. Verified on FFmpeg 9.0.1.
ffmpeg -i input.mp4 -vf "select='gt(scene,0.4)',showinfo" -f null -Read the command