Notes on making movies 3/12/2013-
From JPaul Rinheimer, February 2015
This is the command I use to convert a series of images into movies: ffmpeg on the command line. ffmpeg [https://www.ffmpeg.org/] is a general-purpose, open source audio/video conversion library and is available on Linux, OSX (via Homebrew and natively) and Windows. It has way too many options, however, so it took me a while to get it to work properly. Here's the one-liner I use to create movies from ffmpeg:
ffmpeg -f image2 -r 10 -i im_%05d.png -c:v libx264 -pix_fmt yuv420p test.mp4
- Options to change:
- `-r 10` : frame-rate (10 per second)
- `-i im_%05d.png` file name of the images, i.e. im_00001.png, im_00002.png, ... .
- Other options:
- '-c:v libx264' video codec (same as MPEG4/H.264)
- '-pix_fmt yuv420p' Pixel color format (I think this is needed for it to work properly on OSX)
I haven't used this in awhile, but I remember the quality was the same as the input files and it worked on all systems (I think...).
Jim Bennett notes: Indeed, I use ffmpeg on my Mac all the time (and pretty much that command line) and it is very good. One piece of ffmpeg lore I discovered painfully (and actually not sure it still applies): Make sure your figures have an even number of pixels for height and width. I ensure that using the dpi=<even number> parameter to matplotlib.figure().
From Shih-Nan Chen
- I did not use WhirlGif. I use "convert" which comes with most of the linux distributions, I think. My command to make gif from series of png files:
- convert -delay 10 -layers optimize -loop 0 a*.png animation.gif
- You can put the command in your matlab code via unix(command)
From Parker MacCready
- 10/28/2013 How to make an animated gif:
- First make a folder with a bunch of jpeg's, like I do with pan_plot.m.
- Then, in Photoshop (CS6) do File > Scripts > Load files into stack and select all the jpeg's that you want in the movie. Then at the bottom there is a toolbar called Timeline. Set the button on this to Create Frame Animation and then push this button. At the top right of this is a thingy you can click on to access some commands. Use this to execute (1) Make frames From Layers, (2) Select All Frames, and (3) Reverse Frames (Why?). Then click on a thing on the bottom of one of the frames (in the Animation Window) to set the time interval, e.g. 0.2 seconds. You can also set the number of repetitions there. Finally do File > Save for web and there you can reset the size and save it.
- To look at the result, open the gif with Safari.
From Samantha Siedlecki:
- I have included below the instructions for how to use and the link to how to get whirlgif. Whirlgif generates a movie by concatenating a bunch of individual gif files. To put them in the right order, you need a .in file. I have included one of mine as an example below. To execute whirlgif, from within the directory containing the gif images you wish to make into the movie, enter from the command line the following:
- whirlgif -o movie_filename.gif -i whirlgif-infile
- where movie_filename.gif is the name of the movie file which will result from this action, and infile is the .in file that you create containing the proper order of the gif files. Sometimes you will have to enter ./whirlgif, depending on your settings. Whirlgif is installable on macs as well as Linux. I usually use a script in Ferret to create the gif images.
- Viola! Now you have a gif movie. I used to be able to open them in Quicktime, but no longer. Now I can open them using any internet browser, and they open beautifully in powerpoint or keynote.
- whirlgif can be found here:
From Tom Connolly:
- Here is the command I have used to make movies from jpegs in linux:
mencoder mf://\*.jpg -mf w=640:h=480:fps=10:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -oac copy -o output.avi
I'm not sure what all the flags do, but the "fps" (frames per second) option is useful for slowing down or speeding up the video.
- I found it on this site after a lot of googling: