AMBER Archive (2002)Subject: Re: How to make mpeg files from amber trajectories (fwd)
From: Jake Isaacs (rjisaa0_at_uky.edu)
Date: Tue Aug 27 2002 - 08:48:24 CDT
If you use VMD for viewing trajectories (which I prefer to Moilview)
here is what I've done in the past:
1. Once the trajectory is how you want it (specific atoms/residues,
rotation removed, colored, rendered, etc.) run this "make_frames.tcl"
script in VMD:
for { set i 0 } { $i < 5001 } { set i [ expr $i + 1 ] } {
if { $i < 1 } {
set nm "0000"
} elseif { $i < 10 } {
set nm "000$i"
} elseif { $i < 100 } {
set nm "00$i"
} elseif { $i < 1000 } {
set nm "0$i"
} else {
set nm $i
}
animate goto $i
render Raster3D $nm.r3d
}
You will need to edit the number of frames and the skip increment, if
you want. This will create a xxxx.r3d file for each frame.
2. I like to change the lighting, so I use this "fix_r3d.pl" perl
script:
for ($i = 0; $i <= 5001; $i++) {
if ( $i < 1 ) {$nm = "0000"}
elsif ( $i < 10 ) {$nm = "000$i"}
elsif ( $i < 100 ) {$nm = "00$i"}
elsif ( $i < 1000 ) {$nm = "0$i"}
else {$nm = $i}
open(IN,"$nm.r3d") || die "cannot open $nm.r3d file!\n";
open(OUT,">f$nm.r3d") || die "cannot write f$nm.r3d file!\n";
while (<IN>) {
$_ =~ s/1.00 secondary light
contribution/0.00 secondary light contribution/;
$_ =~ s/0.10 ambient light
contribution/0.40 ambient light contribution/;
print OUT;
}
}
This will give you a "fixed" fxxxx.r3d file for each frame.
3. I liked the results using mpeg_encode (can probably get from sgi
website) over dmconvert, so you'll need to create a ppm file for each
frame. To do this I use the programs render, fromtiff, and toppm. I
use this "make_script.pl" perl script to make a composite executable:
open(OUT,">make_ppm.com") || die "cannot open output file!\n";
for ($i=0; $i<5001; $i++) {
if ( $i < 1 ) {$nm = "0000"}
elsif ( $i < 10 ) {$nm = "000$i"}
elsif ( $i < 100 ) {$nm = "00$i"}
elsif ( $i < 1000 ) {$nm = "0$i"}
else {$nm = $i}
print OUT "render < f$nm.r3d -tiff $nm.tif\nfromtiff $nm.tif
$nm.rgb\ntoppm $nm.rgb $nm.ppm\nrm $nm.r3d f$nm.r3d $nm.tif $nm.rgb\n";
}
You can remove the rm line if you have plenty of disk space and want to
keep all the files. This will leave you with an xxxx.ppm file for each
frame.
4. I use mpeg_encode with this "mpeg.input" parameter file:
PATTERN I
OUTPUT movie-long.mpg
INPUT_DIR .
INPUT
*.ppm [0000-5000]
END_INPUT
BASE_FILE_FORMAT PPM
YUV_SIZE 160x80
INPUT_CONVERT cat *
GOP_SIZE 30
SLICES_PER_FRAME 1
PIXEL HALF
RANGE 10
PSEARCH_ALG LOGARITHMIC
BSEARCH_ALG CROSS2
IQSCALE 8
PQSCALE 10
BQSCALE 25
REFERENCE_FRAME DECODED
Which leaves you with a rather large mpeg file. This file seems to
always work on sgi and mac, but with pc's it works only sometimes,
depending on OS and what program you use to view.
I should stress that this is a highly empirically derived process and
there are probably more elegant ways of doing it. There are plenty of
parameters that I don't understand, especially in the mpeg.input file.
That said, it works for me and produces nice looking movies. If anyone
has suggestions for improvements, I'd love to hear them.
|