Posts Tagged ‘pictures to move’

Pictures to movie: A simple example of avconv

Sunday, February 17th, 2013

In 2011, I travelled from 豊岡 (Toyooka) to 京都 (Kyoto) by train. Every couple of seconds I took a picture with my camera. Since then, I wanted to merge all these pictures into a movie, if possible with some music.

I tried the better known video editors such as OpenShot Video Editor, Pitivi Video Editor, Blender and such but never really got far. Either pictures couldn’t be mass imported or they couldn’t be distributed evenly etc. etc.

Finally, a friend mentioned ffmpeg last week so I tried it again. Unfortunately, ffmpeg seems to be deprecated but they recommend to use avconv instead which comes with “libav-tools”

Format converting is an art of its own, but if you just want the basics, all you need is the following command:

avconv -f image2 -r 3 -i ./%04d.JPG -i soundfile.wav -c copy -crf 20 output.avi

Run this from the folder where your *.JPG pictures are and you will get a movie “output.avi” including a soundtrack from soundfile.wav. “-r 3” means 3 frames per second, so play around with this value if you a ‘faster’ or ‘slower’ movie.
Something else to keep in mind: The pictures must be named in numerical order: 0001.JPG, 0002.JPG etc.
If you don’t have your pictures named like that, try this command (all on 1 line in the terminal):
i=0; for f in *.JPG; do ln -s $f $(printf “%04d.JPG” $i); i=$((i+1)); done
This will create symlinks for all .JPG in your folder in the order that `ln -s` would output them.

This is the result: The final video

As usual, a couple of simple examples in the man page would have been helpful.