
FFMPEG Snippet Collection
FFMPEG is an extremely powerful tool for converting and editing video material. Not only is it ideal for converting to a wide variety of formats, it can also merge image data into video, crop, add filters and even export gif files.
For my own work I can’t imagine my work without this tool. However, the obstacles for getting started are relatively high, because the installation is more or less difficult depending on the operating system. Furthermore, you work with FFMPEG in the command line, which is a daunting task for some people.
I find the technology so helpful because I have to formulate every action with code so that I can reuse it at any time. That saves a lot of work at some point.
In this article I collect FFMPEG snippets that I find especially useful for my work as a designer and creative coder.
Convert one video-format to another
ffmpeg -i in.mov out.mp4
Cut the first 30 seconds of a video
ffmpeg -ss 00:00:30.0 -i input.wmv -c copy -t 00:00:10.0 output.wmv
Merge Audio and Video
ffmpeg -i in.mp4 -i in.wav -c:v copy -c:a aac -shortest output.mp4
Compress Audio
ffmpeg -i input.mp4 -filter_complex "compand=attacks=0:points=-80/-900|-45/-15|-27/-9|-5/-5|20/20" output.mp4
Create images from video
ffmpeg -i input.mp4 -vf fps=1/1 ./thumbs/video%03d.jpg
Concatenate Videos
ffmpeg -i ./input1.mp4 \
-i ./input2.mp4 \
-filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" \
-map "[v]" -map "[a]" ./output.mp4
Add padding / white letterbox
ffmpeg -i input.mp4 -vf "pad=width=900:height=900:x=157:y=45:color=white" output.mp4
Convert video to gif
ffmpeg -i input.mp4 -f gif output.gif
ffmpeg -i input.mp4 -filter_complex "[0:v] palettegen" palette.png
ffmpeg -i input.mp4 -i palette.png -filter_complex "[0:v][1:v] paletteuse" output.gif
ffmpeg -i input.mp4 -filter_complex "[0:v] fps=15,scale=500:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" output.gif
Desaturate Video
ffmpeg -i input -vf hue=s=0 output