Stephen Lindberg

Product Designer @ Iterable

12 January 2020

ffmpeg

Create a video from an image sequence

ffmpeg -r 24 -i img%03d.png -c:v libx264 -pix_fmt yuv420p out.mp4
ffmpeg -apply_trc iec61966_2_1 -r 24 -i %04d.exr -c:v libx264 -pix_fmt yuv420p out.mp4

Batch convert a directory

for i in *.mov; do ffmpeg -i "$i" "${i%.*}.mp4"; done

Resize a video

ffmpeg -i *.mov -vf scale=1280:-2 out.mp4

the -2 part of scale ensures that the final dimension is a multiple of 2. You can use -n for other multiples.

Loop an existing video X times

for i in {1..4}; do printf "file '%s'\n" input.mp4 >> list.txt; done
ffmpeg -f concat -i list.txt -c copy output.mp4

Explode a video into an image sequence

ffmpeg -i input.mp4 -vsync 0 images/%06d.jpg

Remove audio from a video

use the -an flag

ffmpeg -i input.mp4 -c copy -an output.mp4