Last update: February 3, 2023

ffmpeg is one of my favorite command line tool, I'm always amazed by what it's possible to do with it!
I use it quite often for generative art pieces.


ffmpeg -i input.mp4 -vf scale=1024:768 output.mp4
ffmpeg -i input.mp4 -vf scale=320:-1 output.mp4 # Keep aspect ratio


ffmpeg -i 50.mp4 -filter:v "crop=480:360:0:60" 50.2.mp4
ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" out.mp4

Image incrustation

ffmpeg -i input.mp4 -i image.png \
    -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" \
    -pix_fmt yuv420p -c:a copy \

Encode from image list

-framerate = input framerate
-r = output framerate

ffmpeg -framerate 50 -i video_%06d.png -r 50 -pix_fmt yuv420p output.mp4

Scale video

ffmpeg -i in.mp4 -acodec copy -crf 12 -vf scale=1080:1920,setsar=1:1 out.mp4

Convert GIF in videos

for f in *.gif \
do ffmpeg -f gif -i $f -vcodec mpeg4 -y mp4/$f.mp4 \

Accelerate video

Here it's by a factor ten (0.1*)

ffmpeg -i in.mp4 -filter:v "setpts=0.1*PTS" -an out.mp4

Get video length in seconds

ffprobe -i file.mp4 -show_entries format=duration -v quiet -of csv="p=0"

or summing multiples:

for f in *.mp4 \
do sum=$(echo $sum + $(ffprobe -i $f -show_entries format=duration -v quiet -of csv="p=0") | bc) \
done \
echo $sum;


My goal was to get a bunch of PNG frames and make an animation in photoshop, the easiest path has been:

  • ffmpeg -pattern_type glob -i '*.png' video.apng
  • then opening this file and converting it to PSD through the website: https://www.photopea.com
  • then in Photoshop on the animation panel menu (top right of the panel) "Create images from layers"