Ubuntu – How to create a time-lapse video from JPEG images using avconv

avconv

I have a few hundreds of still images. The files are named according to the Canon convention – IMG_2501.JPG, IMG_2502.JPG, IMG_2503.JPG, ....

I've tried:

% avconv -f image2 -i IMG_%04d.JPG avconv_out.avi

avconv version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
built on Nov  9 2013 19:09:46 with gcc 4.8.1
IMG_%04d.JPG: No such file or directory

I guess that IMG_%04d.JPG is not found because avconv expects IMG_0000.JPG, IMG_0001.JPG, .... I can create a symlink for that, but it's a really ugly hack.

How do I create a video from these still photos using avconv without renaming?

Best Answer

Try to rename them first

a=1
for i in *.JPG; do
  new=$(printf "%04d.JPG" ${a}) #04 pad to length of 4
  mv ${i} ${new}
  let a=a+1
done