Make a movie of a pymol structure spinning for powerpoint

UPDATE 5/18/2020: Well, for whatever reason, (at least my version of) Pymol stopped turning the camera (turn command) or molecule (rotate command) in script form, so the below no longer works. Buuutttt. I just told used the drop-down menu to do the movie > program > camera loop > y roll > 4 (or whatever) seconds. And then went to export movie in the file menu and made my movie that way. *shrug*

I’m sure there are many ways to do this, but this is the way I’ve been doing it most recently:

1) Set up your pymol session. That means importing your structure, turning the background to white, and enabling any other setting to make it the desired quality.

2) I use a custom python script to make a series of commands that make the structure turn slightly, ray-trace the structure (for a high quality image), and export the image to a PNG file. The script that I’ve linked to here makes pymol export 360 images, making the structure spin around completely.

Note: Depending on your settings, this process can take 10 minutes or 3 hours. An easy parameter to change would be the resolution (default setting in the script is 2000). Obviously the settings that are toggled during step 1 can drastically change how long it takes as well.

3) Use ffmpeg (at least, on a mac) to turn the 360 images into a video.

$ ffmpeg -framerate 20 -pattern_type glob -i '*.png' -c:v libx264 -preset slow  -profile:v high -level:v 4.0 -pix_fmt yuv420p -vf pad="width=ceil(iw/2)*2:height=ceil(ih/2)*2" -crf 22 -codec:a aac Output.mp4

I used homebrew to install ffmpeg last time I had to do it (brew install ffmpeg). I followed these instructions last time I had to install homebrew.

4) Drag into your powerpoint presentation, and voila!