Create a movie file from single image files (png, jpegs)

Posted April 28th @ 12:49 by Werner

In research sometimes you want to make a movie from single images, like plots from experimental data or from calculation to visualize changes or so on. In order to achieve this you can use ffmpeg. First you have to create the images and save them, where the images need to have a continuous number in the filename, e.g. img0001.png, img0002.png, …, …img5467.png. Take care that there is no image missing and that you have enough zeroes in front of the image number, so that the files are in the correct order.

After you have all the images in a folder, install ffmpeg, in Ubuntu/Debian Linux e.g.

sudo apt-get install ffmpeg

In order to make a movie (mp4 quicktime) out of the images you need to issue the following command

ffmpeg -qscale 5 -r 20 -b 9600 -i img%04d.png movie.mp4

The options are

  • -qscale 5 … define fixed video quantizer scale (VBR) where 1 is the best and 31 the worst. Since mpeg/jpeg has problems to compress line graphics it’s a good idea to set this variable close to 1. You get a big movie file, but otherwise the movie doesn’t look, well, that good.
  • -r … framerate
  • -b … video bitrate
  • -i input files, %04d says that we have four numbers in the filename where the number is filled with zeros left of it.
  • movie.mp4 is the filename, the extension says that it is a quicktime movie. You can also create a Macromedia Flash movie by using the .flv extension.

Links:

5 Trackbacks/Pingbacks

  1. Pingback: Creating Animated Figures with Python + Matplotlib | SciCoder on November 11, 2011
  2. Pingback: Bagaimana membuat movie dari beberapa image? « #include cmath on February 10, 2012
  3. Pingback: saving animation in paraFoam -- CFD Online Discussion Forums on April 9, 2013
  4. Pingback: Python script to export animation images -- CFD Online Discussion Forums on June 4, 2013
  5. Pingback: Creating time-lapse videos with the Nikon D7000 — Part 2 of 2 | spirit's spinney on August 11, 2013

8 Comments

  1. Mario Antonio Herrero Machado
    May 30, 2010 at 00:04

    Thanks, I have put a reference to this article in http://www.gnewbook.org/pg/pages/view/32163/

    Córdoba, Argentina

  2. Mark
    June 7, 2010 at 08:20

    You rock – thanks! Instantly tried it with qscale 1, and it looked flawlessly fluid.

    Mark

  3. Kuvapuisto
    June 8, 2010 at 18:37

    Thenk you! Works perfectly

  4. matteo
    May 4, 2011 at 16:41

    Hi,

    Is there a way to do the same with ONE single image (i.e. still frame) plus an audio file and obtain a video of the same duration as the audio?

    thanks
    m.

  5. Thomas
    May 20, 2011 at 08:58

    Try this to convert image to video.
    ffmpeg -f image2 -i image%d.jpg output.mpg.
    To know more visit: ubuntumanual.org/posts/327/converting-videos-in-ubuntu-using-ffmpeg-the-ultimate-free-video-converter

  6. sebastock
    June 14, 2011 at 00:32

    Thanks, the quality of the video is excellent. The price to pay is the size of the video. In my case, 300Mo for 5000 images.

  7. Werner
    June 14, 2011 at 20:43

    Hi Seb, you could try different qscale values to get smaller but less quality movies.

  8. abhilash
    July 16, 2011 at 07:33

    By running the following command in the shell, FFMPEG can convert a number of different images into a video. ffmpeg -f image2 -i image%d.jpg output.mpg. It is one of the interesting tasks that can be done usin the FFMPEG. Convert videos Ubuntu :

Leave a comment

OpenID Login

Standard Login

 

Options:

Size

Colors