9

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.

Community
  • 1
  • 1
Pietro Speroni
  • 3,131
  • 11
  • 44
  • 55
  • I do not know what you are refering to. The page you link only goes to has a page with 4 colored squares, and it slows down my computer terribly. Are you really trying to help? – Pietro Speroni Jun 03 '09 at 15:37
  • @Pietro: I removed parts of your question because they merely repeated requirements you'd already specified earlier (scriptable, portable, available on the Mac). I also changed the title to phrase it as a question... Please reconsider your rollback. – Shog9 Jun 03 '09 at 16:38
  • 3
    @Rich B: That seems petty of you. – Miles Jun 03 '09 at 16:56
  • @ Rich: First you edited my question cutting away 50 % of the content. You then added a spam link. And when I rolledback keeping the editorial correction but putting back the information you censored you added a second spam link, and then abused of a power that you have in this site, by claiming that the question is non programme related, because the format (and not the content!) are not of your pleasure.You also add all your links as comments that do not permit to get down votes. Please Rich, ignore my questions from now on – Pietro Speroni Jun 03 '09 at 17:23
  • @Rich You deny to have posted this link: bstorer.com/wtf/pogmagic.html & bstorer.com/wtf/pog.html & bstorer.com/wtf/pogtab.html & bstorer.com/wtf/better%20than%20jpg.html ? – Pietro Speroni Jun 03 '09 at 17:29
  • 2
    @Rick: you might feel no problem. I feel I have been bullied by you. Please reconsider how you are helping other people. And if you really can only help by imposing your view, please avoid helping me in future. – Pietro Speroni Jun 03 '09 at 17:42
  • 1
    @Rich B: a) the only aim of those links is to enrage the person, slow their computer, and hinder their work. As such I classify it as spam. b) "That is not in your question"? I don't know what you mean with this phrase in this context. I have refered you how I perceived your "help", how I would prefer to be helped, and if this is not possible how I would prefer to be ignored by you. I am a human being, you are a human being, I am trying to find a common ground so that in future we don't clash again. – Pietro Speroni Jun 03 '09 at 18:02
  • @Rich B — If you don't like "spam", pick whatever term you like for posting malicious links. Either way, it's retaliatory and inappropriate. – Ben Blank Jun 03 '09 at 18:07
  • 2
    @Pietro: You're claiming he edited them into your question, which is false. The comments below the question are not part of the question. They are simply the comments under the question. You're welcome to flag his comments offensive. In fact, they're not even there anymore, as it seems enough people have flagged them. Additionally, this is most definitely /not/ programming related, seeing as you're asking to download a program and not write one. – belgariontheking Jun 03 '09 at 18:08
  • @Ben, thanks for stepping in. In the history of the revisions of this questions, http://stackoverflow.com/revisions/945250/list revision number 2, and revision number 4 were done by Rich. But Rich is right that he wasn't alone in deleting the content. I only saw one edit, and, as I am new to this site, did not know there was an history available. I understand that you don't see this as programming related. I considered it programming related as I was also asking for a possible library in python that permitted me to do this. – Pietro Speroni Jun 03 '09 at 18:18
  • @Rich, if the links were really not malicious you should have explained a bit more how to use them. All I know was that I went to the page, my computer slowed down terribly, a colored square was on the page, and I could not even change the URL. It's hard to believe that you really wanted to help. – Pietro Speroni Jun 03 '09 at 18:21
  • @Rich :) And now is the browser. In any case I have the latest stable version of Firefox. Should I have used IE? – Pietro Speroni Jun 03 '09 at 18:29
  • 2
    @Pietro: FWIW, i've voted to re-open your question. I voted to close it upon first reading it, as I misunderstood what you were asking (thought you were looking for a video editing tool, not a library). Upon realizing my mistake, I undertook the task of editing your question, hoping to clarify it and thus help others avoid the same mistake I made. Rich helped as well, largely by improving the formatting and grammar. For future reference: editors generally try to leave comments in the revision history describing their rationale when making large changes such as this - be sure to check that. – Shog9 Jun 03 '09 at 18:35
  • @Shog9 Thank you. My understanding is that many libraries in python are shells around other programs. And this is why I was looking also for a command-line solution to call them from inside the python program. I appreciate all the effort you guys have done in manking the question more understandable. I feel in this the questions has lost its original flavour. No big deal, but this is why I protested originally. I understand this is not the philosophy behind this site, which seem to be trying to build a huge database of programming related answered questions. – Pietro Speroni Jun 03 '09 at 18:53
  • 1
    @Pietro: you are correct, that is the goal. I do understand your feelings with regard to seeing your words edited - most of us have gone through the same thing at one time or another. But that is the nature of the site, a system which, when it works, is able to produce something better than any one of its participants would be able to alone. Thank you for participating... – Shog9 Jun 03 '09 at 18:58
  • @Shog9 Thanks, but I am not over it yet. Now Rich has gone and edited all the questions I have asked in the past. Sometimes deleting part of the question, the context & the implications: http://stackoverflow.com/revisions/399991/list. And of course this comes with the implicit threat of closing the ones I rollback. This behavior seems childish. More like a way to mark the territory than to be useful. And it can really push users off. In /. users are only given points occasionally to vote. This to avoid abuse of expert users toward new ones. I feel this system lacks a similar balance mechanism. – Pietro Speroni Jun 03 '09 at 19:31
  • @Pietro: No context was lost. I edit many, many questions in a day. Your posts need it. If you feel a post is somehow abusive, feel free to flag it as such. – GEOCHET Jun 03 '09 at 20:03
  • @Pietro: I should also point out that it takes 5 people to close your posts. Perhaps you should try reading the FAQ before getting yourself all in a twist? – GEOCHET Jun 03 '09 at 20:05
  • @Pietro: I looked over the edits to your questions... They appear fairly benign: title statements rephrased as questions, minor spelling, capitalization, and grammar fixes, and in a few cases the removal of superfluous text. I did not see any threats, or edits as substantial as those on this question. Keep in mind, Rich is one of the most active editors on the site - but he is not a moderator and cannot close any questions on his own, even if that was his desire. If you feel something was lost in an edit, consider editing it back in while preserving the other corrections - then everyone wins. – Shog9 Jun 03 '09 at 20:09

3 Answers3

21

If you're not averse to using the command-line, there's 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: ImageMagick v6 Examples - Animation Basics

Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
  • Thanks! I even have already installed ImageMagick long time ago! Now this really solves everything. wooof! – Pietro Speroni Jun 03 '09 at 17:08
  • I realize this is a bit of thread necromancy, but ... you could also install a python API for imagemagick: http://www.imagemagick.org/script/api.php – Daniel B. Mar 05 '16 at 20:56
9

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
  • 1,680
  • 2
  • 15
  • 23
  • 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 Jun 03 '09 at 16:42
  • 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.dmg http://opencv.willowgarage.com/wiki/#Welcome.2BAC8-OS.MacOSXVersion – Daniyar Jun 03 '09 at 16:51
  • 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 Jun 03 '09 at 17:10
4

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

user49117
  • 786
  • 3
  • 9
  • 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 Jun 03 '09 at 15:44
  • 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 Jun 03 '09 at 16:20
  • 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. – user49117 Jun 03 '09 at 16:53