Difference between revisions of "Creating Movies"

From Jmol
Jump to navigation Jump to search
m (Creating movies moved to Creating Movies: consistent naming)
(creating movies, any tips are still welcome)
Line 1: Line 1:
 
{{Tutorials_Sections}}
 
{{Tutorials_Sections}}
  
= What you need =
 
  
 
An animation is just a sequence of images, so all one needs is jmol to create a batch file of images.  
 
An animation is just a sequence of images, so all one needs is jmol to create a batch file of images.  
Line 7: Line 6:
 
It is possible to get the movie output from either one frame at several angles or from a series of frames.
 
It is possible to get the movie output from either one frame at several angles or from a series of frames.
  
The main part of the script is given here: [http://sourceforge.net/mailarchive/message.php?msg_id=46C4DE84.9050805%40stolaf.edu based on a mail from Bob Hanson on the mailing list].
+
= Output Loop Script =
 +
 
 +
The main part of the script is given here: [http://sourceforge.net/mailarchive/message.php?msg_id=46C4DE84.9050805%40stolaf.edu based on a mail from Bob Hanson on the mailing list]. If you want to rotate a single molecule, you need to uncomment the respective 'rotate' commands. If you want to loop over the timeframes in your coordinate file, you only need to change the 'nFrames' variable to the amount of frames you are currently using (this is given in the title of the main Jmol window).
 +
You might also want to change the width and height parameters to create a bigger or smaller video.
 +
 
 
<pre>
 
<pre>
 
name = "./frame0000.jpg";
 
name = "./frame0000.jpg";
Line 21: Line 24:
 
thisFrame = thisFrame + 1;
 
thisFrame = thisFrame + 1;
 
fileName = name.replace("0000","" + ("0000" + thisFrame)[-4][0]);
 
fileName = name.replace("0000","" + ("0000" + thisFrame)[-4][0]);
#rotate x @nDegrees;
+
#rotate x @nDegrees; # use these options if you want to rotate the molecule
 
#rotate y @nDegrees;
 
#rotate y @nDegrees;
 
#rotate z @nDegrees;
 
#rotate z @nDegrees;
frame next;
+
frame next; # only use this if you have a multiframe file.
 
refresh;
 
refresh;
 
write image @width @height @fileName;
 
write image @width @height @fileName;
Line 31: Line 34:
 
</pre>
 
</pre>
  
Save this text in a file, for example movieloop.jmol. Now you still need to load
+
Save this text in a file, for example 'movieloop.jmol'.  
 +
 
 +
= Viewstate =
 +
 
 +
Now you still need to create a viewstate. To do this, load the system coordinates you are interested in, rotate and change background colors until the picture looks as you want it. This can be saved into a file with the command:
 +
 
 +
<pre>
 +
write state "moviestate.jmol"
 +
</pre>
 +
 
 +
A state file look something like this (only some of the important parts are shown):
 +
<pre>
 +
...
 +
load "CoCr_125frames.XYZ";  # This part is essential!
 +
...
 +
cameraDepth = 3.0;
 +
center {6.424099 3.137966 4.133584};
 +
moveto /* time, axisAngle */ 0.0 { -704 -672 -228 173.73} /* zoom, translation */  62.1
 +
2 0.0 0.06  /* center, rotationRadius */ {6.424099 3.137966 4.133584} 9.94055;;
 +
slab 100;depth 0;
 +
...
 +
</pre>
  
= Exporting from a multiframe XYZ file =
+
= Creating a playable movie =
 +
 
 +
To create the animation, make a file with first the viewstate and then the loop, for example by:
 +
<pre>
 +
cat moviestate.jmol movieloop.jmol > movie.jmol
 +
 
 +
jmol movie.jmol
 +
</pre>
 +
 
 +
Jmol will start, and show you the animation, while it is writing the output files.
 +
 
 +
Then the outputfiles need to be combined to a movie, with programs like moviemaker under windows, or under linux with for example the versatile 'convert' program.
 +
 
 +
<pre>
 +
convert *.jpg movie.gif
 +
convert *.jpg movie.mpg
 +
</pre>
  
peichern
+
for the mpg creation additional programs will need to be installed already, convert will output a clear error message if any programs are missing.
1. xyz datei öffnen, ansicht anpassen
 
2. jmol console 'script' starten, da 'write state "formovie.state" '
 
ausführen.
 
3. cat formovie.state movie.jmol > domovie.jmol
 
4. dann 'jmol domovie.jmol' ausführen,
 
5. convert *.jpg out.gif
 

Revision as of 16:08, 12 September 2007

Jmol / JSmol Tutorials


An animation is just a sequence of images, so all one needs is jmol to create a batch file of images. There is currently no menu option to do this, but a small bit of scripting can do the trick. It is possible to get the movie output from either one frame at several angles or from a series of frames.

Output Loop Script

The main part of the script is given here: based on a mail from Bob Hanson on the mailing list. If you want to rotate a single molecule, you need to uncomment the respective 'rotate' commands. If you want to loop over the timeframes in your coordinate file, you only need to change the 'nFrames' variable to the amount of frames you are currently using (this is given in the title of the main Jmol window). You might also want to change the width and height parameters to create a bigger or smaller video.

name = "./frame0000.jpg";
nFrames = 125;
nDegrees = 1;
thisFrame = 0;
width = 640;
height = 480;

set zoomLarge false;

message loop;
thisFrame = thisFrame + 1;
fileName = name.replace("0000","" + ("0000" + thisFrame)[-4][0]);
#rotate x @nDegrees;  # use these options if you want to rotate the molecule
#rotate y @nDegrees;
#rotate z @nDegrees;
frame next; # only use this if you have a multiframe file.
refresh;
write image @width @height @fileName;
if (thisFrame < nFrames);goto loop;endif;
background black;

Save this text in a file, for example 'movieloop.jmol'.

Viewstate

Now you still need to create a viewstate. To do this, load the system coordinates you are interested in, rotate and change background colors until the picture looks as you want it. This can be saved into a file with the command:

write state "moviestate.jmol"

A state file look something like this (only some of the important parts are shown):

...
load "CoCr_125frames.XYZ";  # This part is essential!
...
cameraDepth = 3.0;
center {6.424099 3.137966 4.133584};
moveto /* time, axisAngle */ 0.0 { -704 -672 -228 173.73} /* zoom, translation */  62.1
2 0.0 0.06  /* center, rotationRadius */ {6.424099 3.137966 4.133584} 9.94055;;
slab 100;depth 0;
...

Creating a playable movie

To create the animation, make a file with first the viewstate and then the loop, for example by:

cat moviestate.jmol movieloop.jmol > movie.jmol

jmol movie.jmol

Jmol will start, and show you the animation, while it is writing the output files.

Then the outputfiles need to be combined to a movie, with programs like moviemaker under windows, or under linux with for example the versatile 'convert' program.

convert *.jpg movie.gif
convert *.jpg movie.mpg

for the mpg creation additional programs will need to be installed already, convert will output a clear error message if any programs are missing.