How to make movies

From ChengLab
Revision as of 15:14, 26 August 2020 by Kevin (talk | contribs) (VMD)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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)

From here

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:

  1. From the VMD main click Extensions then Visualization then Movie Maker.
  2. Select your Renderer (Internal Tachyon gives you a much clearer video).
  3. Select your preferred Movie Settings. Make sure to Un-Check the delete image files
  4. 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.
  5. Name your movie.
  6. 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.
  7. Click the Make Movie Button. (Depending which render you are using this process can take an hour or longer).
  8. When the render is complete it may ask you to specify a new path, say no. Now open the command prompt.
  9. 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])
  10. When in the correct folder you will type:
    ffmpeg -r 10 -b 3000k -i yourmovietitle.%04d.bmp yourmovietitle.mp4
  11. 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
  12. Then type dir for directory to make sure that it shows up in the specified folder.
  13. 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:

  1. Load everything into VMD, including psf(if any), pdb and the trajectory
  2. Configure your favorite representations and viewing angles
  3. File > Save Visualisation State
  4. Open the vs_render_$name.vmd to make sure the path to files are correct (especially for Windows)
  5. Put the vs_render_$name.vmd alongside with the coordinate files and change the variable "DCD_DIR=" in the script
  6. Change the variable "name"
  7. (If necessary) Change the render tool in "render TachyonLOptiXInternal \$outdir1/\$filename.tga"
  8. (If necessary) Change "display resize 1920 1080"
  9. 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