This is a read-only mirror of pymolwiki.org
Making Movies
Movie Creation in PyMOL
This page talks about how to take your export movie frames and turn them into an actual movie. For learning how to make a movie in the first place, see MovieSchool.
Encoding video files
Animated GIF
Quality note: Converting to video generally leads to a loss of quality and inflated file sizes. Gif animation gives a good alternative, retaining the original quality and maintaining small file sizes, however it lacks play controls. With skillful use of frame delays during the generation of the Gif it is possible to create pauses to emphasize certain frames. Ulead Gif Animator works well although there are many programs to choose from. To create files with many frames in Ulead add around 150 files as frames at a time.
Avidemux
Avidemux is a great tool to stich your image files together as a movie. It can read the PNG output stack from Pymol and encode a movie using almost all codecs currently available. The program has an easy to use graphical interface, making the conversion simple compared to some of the other options available to you.
Mencoder/Mplayer
Mplayer is an award-winning open source movie player. Mencoder (which comes packaged with Mplayer) is its movie encoder. Mencoder can take in various file formats (png,gif,jpg) and convert them to movies.
Assuming you have created a lot of .png files and would like to encode a .mpeg, .avi or other video format, a number of solutions are known:
- The DiVX encoder using mplayer and mencoder? There's binaries for Unix and Windows. It makes rather nice compression on a 800x600 (probably higher). It doesn't take too long to produce the nicer quailty movies, but much longer than simply
mencoder "mf://*.png" -mf type=png:fps=18 -ovc lavc -o output.avi
namely something like (this command worked BEST for my case; it's all one line connect it where the backslashes are).
mencoder -mc 0 -noskip -skiplimit 0 -ovc lavc -lavcopts \ vcodec=mpeg4:vhq:trell:mbd=2:vmax_b_frames=1:v4mv:vb_strategy=0:vlelim=0:vcelim=0:cmp=6:subcmp=6:precmp=6:predia=3:dia=3:vme=4:vqscale=1 \ "mf://*.png" -mf type=png:fps=18 -o output.avi
The mpeg4 codec requires a DivX plugin which is not a part of the default installation on some operation systems. The codec msmpeg4v2 makes movies which are more likely to be playable on standard Windows players and can be used with mencoder e.g.
mencoder -mc 0 -noskip -skiplimit 0 -ovc lavc -lavcopts vcodec=msmpeg4v2:vhq "mf://*.png" -mf type=png:fps=18 -o output.avi
This encoder line is however not optimised (yet), and the codec also produces a bit larger files than the mpeg4 at the same visual quality according to the Mplayer homepage.
Troubleshooting
- If your movie shows up in PowerPoint with only the first frame showing, or is just a black square, try adding -of asf or -of avi.
- If the above line complains about the codec part, then replace the word codec in the command line with vcodec.
Virtual Dub
Virtual Dub is an open-source, robust piece of software that allows easy creation of .AVI files from image sequences (such as *.PNG created by PyMol). After opening Virtual Dub, select File Menu --> Open Video File --> under "files of type" select image sequence (*.png, etc).
After viewing (and editing) the movie, choose save as AVI (F7) from File menu. This generates high quality, yet very large, AVI files; in order to down-size the files into formats which fit PowerPoint, free software such as FormatFactory (FF) is available for download and easy use.
Keywords
mencoder, mplayer, movie
Other Options
- For those with Photoshop CS3 installed: Load files using File - Scripts - Load Files into Stack. This loads the files as layers. Turn on the animation window at Window - Animation. You may need to reverse the frames for the correct direction - this is done at the animation window using the drop menu above the frames. You will also want to set a delay on the frames, select all frames using the dropdown menu and and then adjust to 0.2s on one of the frames. Then export the film using File - Export - Render Video. There are plenty of options for format and compression types. I found a quicktime movie with no compression at 10f/s to be right for my needs. The video could get quite big, but it will look as good as pymol. Alternatively you can also create animated GIFs in Photoshop. Once you have the frames of your clip as above, choose File - Save for Web and Devices and then save the GIF. The limit of 200 pictures is a problem in Photoshop.
- Another good program for converting images into movies of different formats is VideoMach : http://gromada.com/VideoMach.html
- TMPGEnc from http://www.tmpgenc.net is very fast, easy to use, and produces very nice ouput (MPEG-2). Unfortunately, it does not handle images larger than 720 x 576 pixels.
- Adobe Premiere recipe, using Microsoft's MPEG4 V2, 960x720 @ 30 fps, which PowerPoint automatically treats as full-screen (due it's wacky metrics). Using this codec, a recent 24-second movie consumed only 4.5 MB of space, but looks much better than a 640x480 Cinepak-based movie with a file size of around ~40 MB. It definitely pays to use the latest technology.
- A freeware jiffy to convert png files to an animation is imgcon, which proved to be very useful:http://www.fmrib.ox.ac.uk/~yongyue/imgcondl.html
- The program convert, part of the ImageMagick suite of programs can be used provided the program mpeg2encode is in your path. mpeg2encode can be found here http://www.mpeg.org/MSSG/. To make an mpeg file, go
convert *.png movie.mpeg
If you want to make an animated gif, do
convert *.png movie.gif
Movies on a Mac
QT Pro
On a Mac, it's easy enough to just fire up QuickTime Player and select
File->Open Image Sequence
This will prompt you to select the first png file in a folder and load all other pngs with the same base name in that folder. Then simply export these frames as a movie with any of the available quicktime codecs at a frame rate you like.
Alternative
The above requires QT Pro ($25). For free you can use this: [1].
In a Presentation
You don't need to convert the PyMol scene to a movie, just save session as a .psw (pymol show file) with the scenes embedded in there. Then from within Power|Point just set up a hyperlink (Insert hyperlink) and point it to the .psw file. In presentation mode when you click on the hyperlink pymol automatically boots and you can scroll thru your scens like a full screen powerpoint presentation. You have to make sure that you have pymol installed on your presentation computer (and you have your psw file) and just click OK when powerpoint warns of the perils of non-microsoft products. the final scene will return to your powerpoint presentation without any effort.
Troubleshooting
Quicktime
Recent attention to transparencies and QuickTime show that one typically wants to set
set ray_opaque_background, off
to tell PyMol to stop using Alpha-channel for transparencies and switch to blending.
If you're having transparency problems this could be a fix.