How to make movies
Contents
Look at Gromacs trajectories in VMD
VMD cannot read .top file causing problems of wrongly connected bonds. We can solve this by generating PSF and PDB files. Using ParmEd or PDBReader.
VMD
The GUI method (Credit to Madison Block and Sam Battey)
When setting or changing your working directory or destination folder in the command prompt make sure that if there is a space in your file name, that you put the whole thing in quotation marks. example (incorect way): cd c:\Users\Madison Block\VMD_movie example (the right way): cd “c:\User\Madison Block\VMD_movie” I learned this through trial and error. :) Hope this helps! :)
To make a movie using a PC:
- From the VMD main click Extensions then Visualization then Movie Maker.
- Select your Renderer (Internal Tachyon gives you a much clearer video).
- Select your preferred Movie Settings. Make sure to Un-Check the delete image files
- Set your Working Directory. (This is where your movie file will be placed after the rendering has completed). For faster rendering, you would choose /tmp, because files are saved on the local disk of your computer instead of over lab network to savor.
- Name your movie.
- Change your movie duration from 0 to whatever you want it to be. (A good starting time is 5 to 10 seconds). NOTE: Movies using trajectories cannot have their durations altered.
- Click the Make Movie Button. (Depending which render you are using this process can take an hour or longer).
- When the render is complete it may ask you to specify a new path, say no. Now open the command prompt.
- Make sure that you are in the correct folder in your command prompt. That folder should be where you set your working directory for your movie. (if it is not in the correct folder hit cd ________[whatever the folder name is])
- When in the correct folder you will type:
ffmpeg -r 10 -b 3000k -i yourmovietitle.%04d.bmp yourmovietitle.mp4
- For Windows PowerPoint compatible (insertable) video file, use:
ffmpeg -r 10 -b 3000k -i yourmovietitle.%04d.bmp yourmovietitle.wmv
- There is some syntax to worry about though.
- the input file type has to match what is in your working directory. The image files are often saved as .ppm files for different types of videos, so instead of .bmp as your input, you’ll change it to .ppm.
- The .%04d. has to match the saved files as well. Take a look at the images; they’re saved as “yourmovietitle.0000.bmp.” The .%04d. corresponds to the digits after the title. If there are four digits, you use %04d, if there are five digits you use %05d, ect. ect.
- If you want an output file that isn’t an mp4, simply change the file type in the command line. You could also use the following line of code while in the proper directory:
convert yourmovietitle.mp4 yourmovietitle.desiredfiletype
- the input file type has to match what is in your working directory. The image files are often saved as .ppm files for different types of videos, so instead of .bmp as your input, you’ll change it to .ppm.
- There is some syntax to worry about though.
- Then type dir for directory to make sure that it shows up in the specified folder.
- Then you can go into the working directory folder and double click on your new movie!!! Quicktime should pop up and play the movie.
The CLI style (Script it!)
Scripts on Github-Kev 2019
Movies can be made in VMD by rendering every frame of the trajectory using the command
render TachyonLOptiXInternal \$outdir1/\$filename.tga
You can get a list of render tools by typing "render" in VMD console.
job_render.pbs is a script helps you to loop over all the frames (and add frame numbers).
Breakdown of steps are:
- Load everything into VMD, including psf(if any), pdb and the trajectory
- Configure your favorite representations and viewing angles
- File > Save Visualisation State
- Open the vs_render_$name.vmd to make sure the path to files are correct (especially for Windows)
- Put the vs_render_$name.vmd alongside with the coordinate files and change the variable "DCD_DIR=" in the script
- Change the variable "name"
- (If necessary) Change the render tool in "render TachyonLOptiXInternal \$outdir1/\$filename.tga"
- (If necessary) Change "display resize 1920 1080"
- Just bash it
You could first check your available render method in VMD using
render list
The main idea:
render aasamples TachyonLOptiXInternal 256 render TachyonLOptiXInternal \$outdir1/\$filename.tga
You could either keep the .tga or convert it using ImageMagick
exec convert \$outdir1/\$filename.tga \$outdir2/\$filename.jpg
Lastly, simply:
ffmpeg -framerate 60 -start_number 0 -i snap_%04d.jpg -r 60 -c:v libx264 out.mp4
-framerate and -r set the fps
-c:v libx264 sets H.264
Reverse a movie
ffmpeg -i input.mp4 -vf reverse reversed.mp4
Concat movies
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1 [v]" -map [v] out.mp4
Speed up a move
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" out.mp4
High quality MPG
ffmpeg -i video.mp4 -c:v mpeg2video -q:v 5 -c:a mp2 -f vob video.mpg