Open source · 51 commands
ffmpeg commands, explained
Real-world ffmpeg commands for transforming video, images and audio, grouped by theme.
Each .sh file is a single, copy-paste-ready command or small loop, taken from real projects. The comment header explains what it does and why, what every flag means, which script it came from, and what was changed to bring it up to date. Every ffmpeg example was run against generated test media on ffmpeg 9.0.2.
Each file's Source: line names the original script in this repo that the command came from. The originals were removed once converted and are still in the git history.
Most files read input.mp4 (or input.mov, input.aiff, frames/f%05d.jpg) and write output.* in the current folder. Rename the files or edit the paths to fit your project.
From lucidbeaming/ffmpeg-utilities at v1.0.1, MIT licensed.
Conversion
- Remux to MP4 with the moov atom at the front (faststart) remux-faststart.sh
- Maximum-compatibility web MP4 at the source's own size web-mp4-baseline-keep-size.sh
- Square 600×600 web MP4: H.264 Baseline with loudness-normalized mono audio web-mp4-square-600.sh
- Ogg Theora/Vorbis video (open-format HTML5 fallback) web-ogv-theora-vorbis.sh
- Crush a clip through Xvid, then back to H.264 xvid-roundtrip-crush.sh
Resize and crop
- Fill a 4:3 640×480 frame at 30 fps (scale up, then center-crop) fill-crop-640x480.sh
- Fill a 720×480 (NTSC-sized) frame, silent, small file fill-crop-720x480.sh
- Crop a near-4:3 1434×1080 window from 1080p footage, at 29.97 fps scale-offset-crop-1434x1080.sh
- Vertical 8-second loop from landscape footage (Spotify Canvas–style) vertical-canvas-414x736.sh
Overlays and compositing
- Center a PNG overlay on a 4:3 640×480 video, silent center-png-overlay-4x3.sh
- Center a PNG logo or watermark on a square 720×720 video center-png-overlay-square.sh
- Composite a centered PNG, then edge-detect the whole frame (4:3 1024×768) overlay-then-sobel.sh
- Remove a burned-in logo or timestamp with delogo, at a steady 29.97 fps remove-logo-delogo.sh
- Tile up to 100 clips into a 10×10 1920×1080 mosaic with mixed audio video-mosaic-grid.sh
Stills and GIFs
- Grab a single frame as a 600×600 JPEG (poster image / thumbnail) extract-frame-jpg.sh
- High-quality GIF with a custom palette, in one command palette-gif.sh
Timing and slow motion
- Slow motion by conforming high-frame-rate footage to 29.97 fps (ProRes) conform-to-2997-prores.sh
- Extreme 12.5× slow motion with motion interpolation (butterflow replacement) extreme-slowmo-12x.sh
- Compare minterpolate's motion-estimation settings side by side minterpolate-mode-comparison.sh
- Convert to a steady 29.97 fps with motion interpolation (no speed change) minterpolate-normalize-fps.sh
- Raise footage to 120 fps with interpolated frames, at normal speed minterpolate-raise-fps.sh
- 4× slow motion with motion-interpolated frames (ProRes) minterpolate-slowmo-prores.sh
- 4× interpolated slow motion with matching slowed audio, square 1080×1080 minterpolate-slowmo-with-audio.sh
Effects
- Convert to 1-bit color palette, dithered ditherpunk.sh
- Color-distance map with frei0r colordistance frei0r-colordistance.sh
- Glitched edges with afterimage trails (glitch0r + Sobel + Baltan) frei0r-glitch-sobel-baltan.sh
- Subtle glitches in a spinning, jittering feedback loop (glitch0r + Vertigo + Nervous) frei0r-glitch-vertigo-nervous.sh
- Digital block glitches with frei0r glitch0r (ProRes) frei0r-glitch0r-prores.sh
- "Nervous" 4× slow motion with slowed audio, 4:3 H.264 frei0r-nervous-slowmo-h264.sh
- Jittery "nervous" frame shuffling, stretched into 4× slow motion (ProRes) frei0r-nervous-slowmo-prores.sh
- Sobel edge detection on its own, cropped to 1024×768 frei0r-sobel-edges.sh
- Stretch an image sequence's levels to full black and white normalize-levels.sh
- Shuffled difference-blend glitch in interpolated slow motion random-difference-glitch.sh
- Rhythmic stutter: flash back to an anchor frame between every frame shuffleframes-stutter.sh
- Edge-detected, warped glitch stack (stutter + blend + Sobel + invert) sobel-edge-glitch.sh
Audio visualization
- Audio level histogram video (ahistogram) ahistogram.sh
- Stereo phase meter video (aphasemeter) aphasemeter.sh
- Polar and Lissajous vectorscopes drawn with lines avectorscope-polar.sh
- Stereo vectorscope (Lissajous / goniometer) video from an audio file avectorscope.sh
- Musical spectrum video with showcqt (constant-Q transform) showcqt.sh
- Render an audio file as waveform video, four ways (ProRes for editing) showwaves.sh
Image sequences
- GoPro timelapse photos to a 1080p video, starting mid-sequence gopro-timelapse-start-number.sh
- Convert a sequence of images to a video, filling the frame and cropping to exactly 1920x1080, 3 frames per second, starting at filename with the number 26565 and working through all images with 5 digits of numbers in the filename image-sequence-2-video.sh
- Image sequence to video, filled to 1280×720 with a lowered crop images-to-video-offset-crop.sh
- SVG animation frames to ProRes 4444 with a transparent background svg-frames-to-prores4444-alpha.sh
Batch processing
- Run an ffmpeg command over every file in a folder, then announce it's done batch-loop-with-notification.sh
- Render a set of five audio visualizers for every audio file in a folder render-visualizer-set.sh
- Enlarge or shrink to 1080p, filling the frame and use baseline codec settings for wide compatibility and web presentation standardize-batch.sh
Diagnostics
- Check that this ffmpeg has the encoders, filters and plugins these examples use check-ffmpeg-features.sh
Related tools
- Redraw images as SVGs made of simple shapes, with primitive primitive-png-to-svg.sh
- Transcribe videos and cut a supercut of every time a word is spoken videogrep-supercut.sh