FFmpeg for Animators: 5 Key Commands | QuantumSketch
The 5 FFmpeg commands animators actually need: convert to GIF, trim, concatenate clips, add audio, and compress. Copy-paste recipes with explanations.
The five FFmpeg commands animators actually need: convert to GIF, trim, concatenate clips, add audio, and compress. FFmpeg is the free tool that turns rendered frames into shareable files โ and the same one Manim uses under the hood.
1. MP4 โ clean GIF (two-pass palette)
ffmpeg -i in.mp4 -vf "fps=15,scale=640:-1,palettegen" palette.png
ffmpeg -i in.mp4 -i palette.png -lavfi "fps=15,scale=640:-1,paletteuse" out.gif
The palette pass avoids the banded, ugly GIF a naive one-liner produces.
2. Trim a clip
ffmpeg -i in.mp4 -ss 00:00:03 -to 00:00:08 -c copy out.mp4
-c copy cuts without re-encoding โ instant, lossless.
3. Concatenate clips
# files.txt: file 'a.mp4' / file 'b.mp4'
ffmpeg -f concat -safe 0 -i files.txt -c copy out.mp4
How a series of Manim chunks become one video.
4. Add an audio track
ffmpeg -i video.mp4 -i narration.mp3 -c:v copy -c:a aac -shortest out.mp4
This is the narration merge step, by hand.
5. Compress for the web
ffmpeg -i in.mp4 -vcodec libx264 -crf 23 out.mp4
-crf 18โ28: lower = better quality + bigger file. 23 is a good default.
Quick reference
| Task | Flag |
|---|---|
| No re-encode | -c copy |
| Trim | -ss / -to |
| Quality | -crf |
| Resize | -vf scale=W:-1 |
Skip FFmpeg entirely
QuantumSketch runs FFmpeg for you โ prompt in, finished MP4 out. Installing locally? See ffmpeg not found.
Written by Shihab Shahriar Antor ยท Shahriar Labs
FAQ
Q.What is FFmpeg and why do animators use it?
FFmpeg is a free, open-source command-line tool for converting, editing, and encoding audio and video. Animators use it because tools like Manim render raw frames or video chunks that need to be turned into a final file โ encoded to MP4, converted to GIF for the web, trimmed, joined together, or have audio added. FFmpeg does all of this in a single command without opening a heavyweight editor, which makes it ideal for scripted, repeatable pipelines. It's the same tool that runs under the hood when Manim produces its output video.
Q.How do I convert a video to a GIF with FFmpeg without it looking bad?
Generate a color palette first, then use it. A naive ffmpeg -i in.mp4 out.gif produces a small, banded GIF because GIF supports only 256 colors chosen poorly. The two-pass method โ ffmpeg -i in.mp4 -vf palettegen palette.png, then ffmpeg -i in.mp4 -i palette.png -lavfi paletteuse out.gif โ builds an optimal palette from the actual video and gives a much cleaner result. You can also scale down with -vf scale=640:-1 and cap the frame rate with fps=15 to keep the file size reasonable for web use.