13

I have 400 PNG images, from which I want to generate a Quicktime movie (.mov). The filenames have the style:

img1.png
img2.png
...
img10.png
imp11.png
...
img100.png
img101.png
...

I used to do that on a Mac using ImageJ but unfortunately this requires a 32 bit version of Java. I also tried it using ImageJ on Ubuntu, but the option to create a Quicktime movie does not exist there.

  • What version (i.e., version number) of ImageJ did you use on OS X, and what version are you using on Ubuntu? – Eliah Kagan Mar 19 '13 at 8:57
7

I'd do it with avconv (or ffmpeg), but you have to do it on the command line.

Install required program

Open the terminal application and install the required programs:

sudo apt-get install libav-tools libavcodec-extra-53 libavdevice-extra-53 libavformat-extra-53 libavutil-extra-51 libpostproc-extra-52 libswscale-extra-2

Go to the directory containing the image sequence:

cd /path/to/images/

Convert:

avconv -i "img%d.png" -r 25 -c:v libx264 -crf 20  -pix_fmt yuv420p img.mov
  • -i "img%d.png" uses these files as the input, %d is a placeholder for the number
  • -r 25 the desired frame rate, 25 FPS in this case
  • -c:v libx264 use the h264 codec x264
  • -crf 20 the video quality, 20 is pretty high, the default is 23
  • -pix_fmt yuv420p a compatible pixel format

Note that in contrast to e.g. VLC, older quicktime players are pretty picky about what they play. Be sure to test it in quick time, you may have to adapt the codec options / output format (For example, you could replace img.mov with img.mkv to get a Matroska video)

avconv doc

  • Default frame rate for input is -r 25, so if you choose a different value for output then ffmpeg will drop or duplicate frames to compensate. Sometimes this is desired by the user. If not then use -r as an input option instead. – llogan Jan 31 '14 at 19:51
  • Packages required on Ubuntu 14.04: sudo apt-get install libav-tools libavcodec-extra-54 libavdevice-extra-53 libavformat-extra-54 libavutil-extra-52 libswscale-extra-2 – Damien Feb 23 '16 at 0:18
7

I'd highly recommend Imagemagick for this. After installing it, an example of a command for what you're trying to do would be:

convert -delay 5 img[1-9].png img[1-9][0-9].png img[1-9][0-9][0-9].png output.mov

Note that the command would be simpler (and the images would still show up in numerical order) if you had leading zeros in your image filenames. Then you could use:

convert -delay 5 img*.png output.mov
0

You could use the Fiji distribution of ImageJ on ubuntu and enable the FFMPEG repository, which gives you the option to export (File > Save as) as MPEG movie. Although this depends wether an MPEG is ok for you or you have to go for QuickTime.

For help in enabling the FFMPEG repository, see the corresponding page in Fiji's excellent wiki.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.