Here are two example scripts for making movies in VMD. The first is shown below and the other controls the camera to follow an interesting part of the simulation.
Rotate and Change Representation
This script makes a movie of the molecule rotating and stops halfway to change the representation. Most of the script is set-up. The loop to make the movie starts on line 75.
Complex Camera Movement
This script follows a list of key-points with the camera given by an external file (called hindices.txt
).
In the example, the camera is following the positive charge site of a hydronium ion from an ab initio molecular
dynamics simulation. The simulation is from White et al.(White et al., 2017).
Converting frames into a movie
Here’s how you actually convert the images coming from VMD and these scripts into a movie using the ffmpeg
program. Make sure you
set your render size to match the movie size (there is a line in the scripts for this).
ffmpeg -framerate 60 -f image2 -i animate.%04d.dat.tga -c:v h264 -crf 5 -c:v libx264 -movflags +faststart -vf scale=800:600,format=yuv420p out.mp4
References
- White, A. D., Knight, C., Hocky, G. M., & Voth, G. A. (2017). Communication: Improved ab initio molecular dynamics by minimally biasing with experimental data. Journal of Chemical Physics, 146(4). https://doi.org/10.1063/1.4974837