posted on: 2017-11-28 04:27:35
This describes three basic steps to creating a stop motion from a webcam in linux using ffmpeg.

The first thing to do is to collect frames every x second. I found 10 per second looks ok.

    ffmpeg -i /dev/video0 -vf fps=1/10 out%03d.png 

This will leave a directory full of single frames. So we have to grab all of the single frames.

    ffmpeg -i out%03d.png -b:v 0 -crf 32 -r 5 out2.webm

I use the crf to improve the quality. It isn't necessary.

Finally I had 3 movies so I patched them together by creating a file list:

file 'out.webm'
file 'out3.webm'
file 'out2.webm'

and concatenating.

ffmpeg -f concat -i mylist.txt -c copy combo.webm

The result is

Another example would be to create a time lapse directly from a video.

ffmpeg -i out.mp4 -vf "setpts=0.2*PTS" -b 0 -crf 32 double.webm

That speeds up the movie about 5x's.