Michael Svanström

developer, photographer

ffmpeg: jpegs to h.264 video

Create stopmotion on Linux? Resize all jpeg’s in the current folder and rename them sequencially:

 counter=0;
 for file in *jpg;
 do counter=`expr $counter + 1`;
 newfile=`printf %04d $counter`; mv $file $newfile.jpg;
 done;
 mogrify -resize 1920x1920 -crop 1920x1080+0+200 *jpg

This command will turn all .jpg’s (001.jpg, 002.jpg…) in current directory into an x264 encoded full HD 6 Mbit/s mp4 video.

$ ffmpeg -i %03d.jpg -vcodec libx264 -vpre hq -r 25 -s 1920x1080 -acodec libfaac -ab 96k -b 10M output.mp4

Update: For editing, DNxHD may be more suitable. $ ffmpeg -i %03d.jpg -vcodec dnxhd -b 10M -an output.mov