Transform images into videos with images2mpg

67

Author: Shashank Sharma

images2mpg, a simple utility that’s part of the KDE Image Plugin Interface (KIPI), lets you create an MPEG file from image files. Relying on a handful of command-line tools including the ImageMagick suite and mjpegtools, images2mpg creates wonderful videos from your images and even lets you insert your favorite song as the background. It supports SVCD, DVD, VCD, and XVCD video formats.

To install KIPI, Fedora and Ubuntu users can respectively use yum or apt. Before you begin experimenting with images2mpg, you will need to install ImageMagick and mjpegtools too.

The following command creates a SVCD file using three images files: images2mpg -f SVCD -d 4 -o car.mpg -i DSC00475.JPG DSC00468.JPG DSC00477.JPG. In this command, the -d command switch specifies the duration in seconds for which each image will be visible.

You can set a transition between images using the -t switch, which invokes the composite utility from ImageMagick to create the transition effect: images2mpg -f SVCD -d 4 -t 2 -o car.mpg -i DSC00475.JPG DSC00468.JPG DSC00477.JPG. The -t switch accepts a value of 1, 2, 4, 5, 10, or 20, which represents the speed of the transition between images.

The resolution for SVCD files created by images2mpg is 576×480, with 25 frames per second (fps). images2mpg uses the montage utility from the ImageMagick suite to resize the images, so you don’t have to worry if all your images are of different resolutions.

If no output format is specified, images2mpg creates a XVCD file of 720×576 resolution at 25fps and video bitrate of 2500Kbps. While the audio bitrate for each of the files, be it DVD, VCD, XVCD, or SVCD, is the same at 224Kbps, the video bitrate varies. The bitrate for each of the supported file formats is listed in the man page for images2mpg, along with other details such as the resolution and frame rate.

To add audio to your movie file, use the -w switch to insert a WAV file or the -a switch if it’s MP2 audio. Surprisingly, while the man page for images2mpg does not state this, you need to use the -S switch to successfully create a movie file with audio. images2mpg uses the mplex utility provided by mjpegtools to merge the encoded audio stream with the video file. Without the -S switch, this step fails. So, to create a movie file with audio, use a command like images2mpg -f SVCD -S 420mpeg2 -d 2 -t 2 -w ~/Music/mytune.wav -o car.mpg -i *.jpg

You can even specify an MP3 file as the background audio when you use the -S switch. The -S switch is used to set the chroma subsampling mode. Every time you use images2mpg, it will present a detailed information sheet of all the steps involved in creating the video, along with information about the number of images used, the video format, number of frames, and other information:

$ images2mpg -f SVCD -S 420mpeg2 -w ~/Music/audio.mp3 -d 2 -t 2 -T tmp/ -o testing_temp.mpg -i DSC004* ------------------------------------------------ Number of image file(s) : 3. Processing sequence : DSC00468.JPG DSC00475.JPG DSC00477.JPG Video format : 'SVCD'. Video type : 'PAL'. WAV audio file : 'big.wav'. Frames per second : '25'. Image duration : 2 s. Total video sequence duration : 14 s . Transition frames : 50. Total frames processing : 350. Background image file : 'tmp//1211114534.black.tmp.png'. Verbosity : 'none'. ------------------------------------------------ Encoding 3 image(s) MPEG sequence with ImageMagick and MjpegTools. INFO: [yuvscaler] yuvscaler 1.9.0 (15-02-2004) is a general scaling utility for yuv frames INFO: [yuvscaler] (C) 2001-2004 Xavier Biquard , yuvscaler -h for help, or man yuvscaler ++ WARN: [mpeg2enc] Generating dummy SVCD scan-data offsets to be filled in by "vcdimager" ++ WARN: [mpeg2enc] If you're not using vcdimager you may wish to turn this off using -d Frame Num. 350 / 350 MPEG encoding terminated [350 frames - Encoding time : 279 s]. Encoding MPG layer 2 audio file from big.wav WAV file with MjpegTools. big.wav: audio/x-wav Merging MPEG flux with MjpegTools. The video MPEG output file is 'testing_temp.mpg'. Removing temporary files...

The process of creating a movie from your images may take some time, depending on how many images you are using, the transition time between each image, the duration for which each image is displayed, and so on, because all these variables determine the total number of frames in the video. The high quality of movies created with images2mpg and its ease of use make images2mpg a great command-line tool to convert still images into entertaining videos.

Categories:

  • Graphics & Multimedia
  • Shell & CLI