Skip to content
Snippets Groups Projects
Commit b7c54dc3 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

new rotate script + refactored the anim script into 2 separate files
parent a64cd7f4
No related branches found
No related tags found
No related merge requests found
// A demo script to save mpeg or gif animations of post-processing views
// This script creates an mpeg or gif animation by looping over all
// the time steps and/or all the post-processing views
all = GetValue("Animate one view at a time or all views together?
......@@ -10,7 +11,7 @@ neww = GetValue("Width of animation? (enter 0 to keep current width)", 640);
oldh = General.GraphicsHeight;
newh = GetValue("Height of animation? (enter 0 to keep current height)", 640) ;
method = GetValue("Animation method?
method = GetValue("Animation encoder?
0: mpeg_encode (MPEG1), 1: mencoder (MPEG4), 2: whirlgif (GIF89)", 0) ;
MPEG_ENCODE = 0;
......@@ -77,54 +78,10 @@ If(!all)
EndFor
EndIf
If(method == WHIRLGIF)
// Call whirlgif
System "whirlgif -minimize -loop -o /tmp/animation.gif /tmp/tmp*.gif" ;
EndIf
If(method == MENCODER)
// Call mencoder
System "mencoder 'mf:///tmp/tmp*.jpg' -mf fps=5 -o /tmp/animation.mpg -ovc lavc -lavcopts vcodec=mpeg4:vhq";
// System "mencoder 'mf:///tmp/tmp*.jpg' -mf fps=5 -o /tmp/animation.mpg -ovc lavc -lavcopts vcodec=mpeg1video:vhq";
EndIf
If(method == MPEG_ENCODE)
// create the parameter file for mpeg_encode
System 'echo "PATTERN I" > /tmp/tmp.par' ;
System 'echo "BASE_FILE_FORMAT JPEG" >> /tmp/tmp.par' ;
System 'echo "GOP_SIZE 30" >> /tmp/tmp.par' ;
System 'echo "SLICES_PER_FRAME 1" >> /tmp/tmp.par' ;
System 'echo "PIXEL HALF" >> /tmp/tmp.par' ;
System 'echo "RANGE 10" >> /tmp/tmp.par' ;
System 'echo "PSEARCH_ALG TWOLEVEL" >> /tmp/tmp.par' ;
System 'echo "BSEARCH_ALG CROSS2" >> /tmp/tmp.par' ;
System 'echo "IQSCALE 1" >> /tmp/tmp.par' ;
System 'echo "PQSCALE 10" >> /tmp/tmp.par' ;
System 'echo "BQSCALE 25" >> /tmp/tmp.par' ;
System 'echo "REFERENCE_FRAME DECODED" >> /tmp/tmp.par' ;
System 'echo "OUTPUT /tmp/animation.mpg" >> /tmp/tmp.par' ;
System 'echo "INPUT_CONVERT *" >> /tmp/tmp.par' ;
System 'echo "INPUT_DIR /tmp" >> /tmp/tmp.par' ;
System 'echo "INPUT" >> /tmp/tmp.par' ;
System Sprintf('echo "tmp*.jpg [001-%03g]" >> /tmp/tmp.par', index) ;
System 'echo "END_INPUT" >> /tmp/tmp.par' ;
// Call mpeg_encode
System "mpeg_encode /tmp/tmp.par" ;
EndIf
// Clean-up temp files?
cleanup = GetValue("Remove temporary files?
(The final animation has been saved in /tmp/animation.{gif.mpg})", 1);
If(cleanup)
If(method == WHIRLGIF)
System "rm -f /tmp/tmp*.gif" ;
EndIf
If(method == MPEG_ENCODE || method == MENCODER)
System "rm -f /tmp/tmp*.jpg /tmp/tmp.par" ;
EndIf
EndIf
NUM_FRAMES = index;
ENCODER = method;
Include "encode.script";
General.GraphicsWidth = oldw;
General.GraphicsHeight = oldh;
// This script encodes the image files
//
// /tmp/tmp[001-NUM_FRAMES].{gif,jpg}
//
// into an mpeg or gif animation, using the encoder ENCODER
// (set to WHIRLGIF, MENCODER or MPEG_ENCODE)
If(ENCODER == WHIRLGIF)
// Call whirlgif
System "whirlgif -minimize -loop -o /tmp/animation.gif /tmp/tmp*.gif" ;
EndIf
If(ENCODER == MENCODER)
// Call mencoder
System "mencoder 'mf:///tmp/tmp*.jpg' -mf fps=5 -o /tmp/animation.mpg -ovc lavc -lavcopts vcodec=mpeg4:vhq";
// System "mencoder 'mf:///tmp/tmp*.jpg' -mf fps=5 -o /tmp/animation.mpg -ovc lavc -lavcopts vcodec=mpeg1video:vhq";
EndIf
If(ENCODER == MPEG_ENCODE)
// create the parameter file for mpeg_encode
System 'echo "PATTERN I" > /tmp/tmp.par' ;
System 'echo "BASE_FILE_FORMAT JPEG" >> /tmp/tmp.par' ;
System 'echo "GOP_SIZE 30" >> /tmp/tmp.par' ;
System 'echo "SLICES_PER_FRAME 1" >> /tmp/tmp.par' ;
System 'echo "PIXEL HALF" >> /tmp/tmp.par' ;
System 'echo "RANGE 10" >> /tmp/tmp.par' ;
System 'echo "PSEARCH_ALG TWOLEVEL" >> /tmp/tmp.par' ;
System 'echo "BSEARCH_ALG CROSS2" >> /tmp/tmp.par' ;
System 'echo "IQSCALE 1" >> /tmp/tmp.par' ;
System 'echo "PQSCALE 10" >> /tmp/tmp.par' ;
System 'echo "BQSCALE 25" >> /tmp/tmp.par' ;
System 'echo "REFERENCE_FRAME DECODED" >> /tmp/tmp.par' ;
System 'echo "OUTPUT /tmp/animation.mpg" >> /tmp/tmp.par' ;
System 'echo "INPUT_CONVERT *" >> /tmp/tmp.par' ;
System 'echo "INPUT_DIR /tmp" >> /tmp/tmp.par' ;
System 'echo "INPUT" >> /tmp/tmp.par' ;
System Sprintf('echo "tmp*.jpg [001-%03g]" >> /tmp/tmp.par', NUM_FRAMES) ;
System 'echo "END_INPUT" >> /tmp/tmp.par' ;
// Call mpeg_encode
System "mpeg_encode /tmp/tmp.par" ;
EndIf
// Clean-up temp files?
cleanup = GetValue("Remove temporary files?
(The final animation has been saved in /tmp/animation.{gif,mpg})", 1);
If(cleanup)
If(ENCODER == WHIRLGIF)
System "rm -f /tmp/tmp*.gif" ;
EndIf
If(ENCODER == MPEG_ENCODE || ENCODER == MENCODER)
System "rm -f /tmp/tmp*.jpg /tmp/tmp.par" ;
EndIf
EndIf
// This script creates an mpeg or gif animation by applying
// incremental rotations around the 3 coordinate axes
oldw = General.GraphicsWidth;
neww = GetValue("Width of animation? (enter 0 to keep current width)", 640);
oldh = General.GraphicsHeight;
newh = GetValue("Height of animation? (enter 0 to keep current height)", 640);
method = GetValue("Animation encoder?
0: mpeg_encode (MPEG1), 1: mencoder (MPEG4), 2: whirlgif (GIF89)", 0);
MPEG_ENCODE = 0;
MENCODER = 1;
WHIRLGIF = 2;
steps = GetValue("Number of steps", 360);
xinc = GetValue("X-axis rotation increment (in degrees)", 0);
yinc = GetValue("Y-axis rotation increment (in degrees)", 1);
zinc = GetValue("Z-axis rotation increment (in degrees)", 0);
If(neww)
General.GraphicsWidth = neww;
EndIf
If(newh)
General.GraphicsHeight = newh;
EndIf
Print.JpegQuality = 100;
General.Trackball = 0;
General.Light0X = 1;
General.Light0Y = 0;
General.Light0Z = 0;
index = 0;
For (1:steps)
General.RotationX += xinc;
General.RotationY += yinc;
General.RotationZ += zinc;
index++;
Draw;
If(method == WHIRLGIF)
Print Sprintf("/tmp/tmp%03g.gif", index);
EndIf
If(method == MPEG_ENCODE || method == MENCODER)
Print Sprintf("/tmp/tmp%03g.jpg", index);
EndIf
EndFor
NUM_FRAMES = index;
ENCODER = method;
Include "encode.script";
General.GraphicsWidth = oldw;
General.GraphicsHeight = oldh;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment