tags:

views:

461

answers:

3

I managed to get a set of images loaded using Python.

I'd like my script to take this series of images (in whatever format I need them), and create a video from them. The big limit in all this is that I am looking for something easy and simple to install. Ideally, using the standard OS X installation procedure:

  • download .dmg
  • click
  • move into the application folder

I do not want to expend a lot of effort to install the video editing program. Just something simple that works.


Questions

  1. What format should I aim for? I need my video to be playable on Linux, Mac, and Windows systems. The images are graphs, so we are speaking of discreet images, not photographs. It should be pretty easy to compress it. There will be about 1000 images, so this will be a short movie.

  2. What tools should I use to produce the actual video? I need to either do it directly from Python using a library designed for this purpose, or by scripting command-line tools called from Python.

+2  A: 

Do you have to use python? There are other tools that are created just for these purposes. For example, to use ffmpeg or mencoder.

Thank you. ffmpeg was the first I visited, but I was scared of the installation procedure. I don't know anything about mencoder. Can it create video, it seems just a conversion tool
Pietro Speroni
So mencoder does not seem to permit to make a video out of a series of images. I also downloaded ffmpegx, which uses the same technology (it requires mencoder) and also it does not let you create video.
Pietro Speroni
mencoder can do this too. The liked page in my post has examples for this.About installation, will macports or fink do the job? Note that I am not a mac user.
+3  A: 

You may use OpenCV. And it can be installed on Mac. Also, it has a python interface.

I have slightly modified a program taken from here, but don't know if it compiles, and can't check it.

import opencv
from opencv.cv import *
from opencv.highgui import *

isColor = 1
fps     = 25  # or 30, frames per second
frameW  = 256 # images width
frameH  = 256 # images height
writer = cvCreateVideoWriter("video.avi",-1, 
fps,cvSize(frameW,frameH),isColor)

#-----------------------------
#Writing the video file:
#-----------------------------

nFrames = 70; #number of frames
for i in range(nFrames):
    img = cvLoadImage("image_number_%d.png"%i) #specify filename and the extension
     # add the frame to the video
    cvWriteFrame(writer,img)

cvReleaseVideoWriter(writer) #
Daniyar
Thank you. It's not exactly simple to install OpenCV. Especially for those of us who have not managed to get svn working (i.e. me). I shall see what I can do, but I really appreciate your code. It gives me hope that if I can get this program on, then it's downhill.
Pietro Speroni
Can't help you with that, I'm not a Mac user.Did you check this:http://www.ient.rwth-aachen.de/~asbach/OpenCV-Private-Framework-1.2.dmghttp://opencv.willowgarage.com/wiki/#Welcome.2BAC8-OS.MacOSXVersion
Daniyar
Sorry, to be fully onest I had to move the "accepted answer" to the other answer that uses imagemagick, as that is the one I will use. I appreciate all the work that you have done.
Pietro Speroni
+6  A: 

If you're not averse to using the command-line, there the 'convert' command from the ImageMagick package. It's available for Mac, Linux, Windows. See http://www.imagemagick.org/script/index.php.

It supports a huge number of image formats and you can output your movie as an mpeg file:

convert -quality 100 *.png outvideo.mpeg

or as animated gifs for uploading to webpages:

convert -set delay 3 -loop 0 -scale 50% *.png animation.gif

More options for the 'convert' command available here: http://www.imagemagick.org/Usage/anim_basics/

lsc
Thanks! I even have already installed ImageMagick long time ago! Now this really solves everything. wooof!
Pietro Speroni