FFMPEG Snippet Collection
FFMPEG is a very small and handy tool for converting and editing media from the command-line. 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.
Cut video
ffmpeg -ss 00:00:30.0 -i input.wmv -c copy -t 00:00:10.0 output.wmv
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
Scale video while keeping the aspect ratio
ffmpeg -i in.mp4 -vf scale=720:-2 out.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
Create a video from a folder of images
ffmpeg -r 30 -i ./%09d.png output.mp4
Reset dimensions
ffmpeg -i in.mp4 -vf scale=800:600,setsar=1:1 out.mp4
Generate a video from an image and a sound-file
ffmpeg -loop 1 -i in.jpg -i in.mp3 -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p -shortest out.mp4
Compressing / Scaling video
ffmpeg -i for.mp4 -vf scale=-1:720 -c:v libx264 -crf 40 -preset veryslow -c:a copy for_opt.mp4
Related
The Story of 128KB
One day in January 2024, I was lethargically scrolling through my Instagram feed on my laptop. And, as so often […]
Lo-Fi Collage Machine
Click here to login or connect!To view this content, you must be a member of Tim's Patreon at €10 or […]
Diogenes meets Demo Festival
Below is the written version of my talk at DEMO Festival in Amsterdam, January 2025. I’ve also recorded an audio […]
The Magic Triangle
The Magic Triangle is a powerful creativity technique that can be applied to many different areas.
Design is dead – long live Design!
I have been observing developments in design for 40 years. That may sound strange, as I’m only forty myself, but […]
Omid Nemalhabib on Design within Limitations
I met Omid Nemaldhabib quite coincidentally in Rotterdam in 2022. He comes from Tehran and ran a design studio there […]
It’s Nice That POV: What happens when design ditches big tech?
I’ve had the great pleasure to chat with It’s Nice That editor Lucy Bourton about some of the aspects of […]
Back to the Future of the Internet
About a year ago, in February 2024, I was a invited speaker at an event at the Akasha Hub in […]