How to generate a MOV-file from PNG images?
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.
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
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