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

create mpeg_encode parameter file on the fly

parent 09d69bf8
No related branches found
No related tags found
No related merge requests found
/********************************************************************* /*********************************************************************
* *
* Gmsh tutorial 8 * Gmsh tutorial 8
* *
* Post-processing, scripting, animations, options * Post-processing, scripting, animations, options
* *
*********************************************************************/ *********************************************************************/
...@@ -15,7 +15,7 @@ Include "view4.pos"; ...@@ -15,7 +15,7 @@ Include "view4.pos";
// We then set some general options: // We then set some general options:
General.Trackball = 0; General.Trackball = 0;
General.RotationX = 0; General.RotationY = 0; General.RotationZ = 0; General.RotationX = 0; General.RotationY = 0; General.RotationZ = 0;
General.Color.Background = White; General.Color.Foreground = Black; General.Color.Background = White; General.Color.Foreground = Black;
General.Color.Text = Black; General.Color.Text = Black;
...@@ -53,15 +53,14 @@ View[v2].Height = 130; ...@@ -53,15 +53,14 @@ View[v2].Height = 130;
View[v3].Visible = 0; View[v3].Visible = 0;
// We then loop from 1 to 255 with a step of 1. (To use a different // We then loop from 1 to 3 with a step of 1. (To use a different
// step, just add a third argument in the list. For example, `For num // step, just add a third argument in the list. For example, `For num
// In {0.5:1.5:0.1}' would increment num from 0.5 to 1.5 with a step // In {0.5:1.5:0.1}' would increment num from 0.5 to 1.5 with a step
// of 0.1.) // of 0.1.)
t = 0; t = 0;
//For num In {1:1} For num In {1:3}
For num In {1:255}
View[v0].TimeStep = t; View[v0].TimeStep = t;
View[v1].TimeStep = t; View[v1].TimeStep = t;
...@@ -69,30 +68,35 @@ For num In {1:255} ...@@ -69,30 +68,35 @@ For num In {1:255}
View[v3].TimeStep = t; View[v3].TimeStep = t;
t = (View[v0].TimeStep < View[v0].NbTimeStep-1) ? t+1 : 0; t = (View[v0].TimeStep < View[v0].NbTimeStep-1) ? t+1 : 0;
View[v0].RaiseZ += 0.01/View[v0].Max * t; View[v0].RaiseZ += 0.01/View[v0].Max * t;
If (num == 3) If (num == 3)
// We want to create 320x240 frames when num == 3: // We want to create 640x480 frames when num == 3:
General.GraphicsWidth = 320; General.GraphicsWidth = General.MenuWidth + 640;
General.GraphicsHeight = 240; General.GraphicsHeight = 480;
EndIf EndIf
frames = 50;
// It is possible to nest loops: // It is possible to nest loops:
For num2 In {1:50} For num2 In {1:frames}
General.RotationX += 10; General.RotationX += 10;
General.RotationY = General.RotationX / 3; General.RotationY = General.RotationX / 3;
General.RotationZ += 0.1; General.RotationZ += 0.1;
Sleep 0.01; // sleep for 0.01 second Sleep 0.01; // sleep for 0.01 second
Draw; // draw the scene Draw; // draw the scene
If (num == 3) If (num == 3)
// The `Print' command saves the graphical window; the `Sprintf' // The `Print' command saves the graphical window; the `Sprintf'
// function permits to create the file names on the fly: // function permits to create the file names on the fly:
/*
Print Sprintf("t8-%02g.gif", num2); Print Sprintf("t8-%02g.gif", num2);
Print Sprintf("t8-%02g.ppm", num2);
Print Sprintf("t8-%02g.jpg", num2); Print Sprintf("t8-%02g.jpg", num2);
*/
EndIf EndIf
EndFor EndFor
...@@ -101,25 +105,48 @@ For num In {1:255} ...@@ -101,25 +105,48 @@ For num In {1:255}
// Here we could make a system call to generate a movie. For example, // Here we could make a system call to generate a movie. For example,
// with whirlgif: // with whirlgif:
// /*
// System "whirlgif -minimize -loop -o t8.gif t8-*.gif"; System "whirlgif -minimize -loop -o t8.gif t8-*.gif";
*/
// with mpeg_encode:
// // with mpeg_encode (create parameter file first, then run encoder):
// System "mpeg_encode t8.par"; /*
Printf("PATTERN I") > "t8.par";
Printf("BASE_FILE_FORMAT PPM") >> "t8.par";
Printf("GOP_SIZE 1") >> "t8.par";
Printf("SLICES_PER_FRAME 1") >> "t8.par";
Printf("PIXEL HALF") >> "t8.par";
Printf("RANGE 10") >> "t8.par";
Printf("PSEARCH_ALG EXHAUSTIVE") >> "t8.par";
Printf("BSEARCH_ALG CROSS2") >> "t8.par";
Printf("IQSCALE 1") >> "t8.par";
Printf("PQSCALE 1") >> "t8.par";
Printf("BQSCALE 25") >> "t8.par";
Printf("REFERENCE_FRAME DECODED") >> "t8.par";
Printf("OUTPUT t8.mpg") >> "t8.par";
Printf("INPUT_CONVERT *") >> "t8.par";
Printf("INPUT_DIR .") >> "t8.par";
Printf("INPUT") >> "t8.par";
tmp = Sprintf("t8-*.ppm [01-%02g]", frames);
Printf(tmp) >> "t8.par";
Printf("END_INPUT") >> "t8.par";
System "mpeg_encode t8.par";
*/
// with mencoder: // with mencoder:
// /*
// System "mencoder 'mf://*.jpg' -mf fps=5 -o t8.mpg -ovc lavc System "mencoder 'mf://*.jpg' -mf fps=5 -o t8.mpg -ovc lavc
// -lavcopts vcodec=mpeg1video:vhq"; -lavcopts vcodec=mpeg1video:vhq";
// System "mencoder 'mf://*.jpg' -mf fps=5 -o t8.mpg -ovc lavc System "mencoder 'mf://*.jpg' -mf fps=5 -o t8.mpg -ovc lavc
// -lavcopts vcodec=mpeg4:vhq"; -lavcopts vcodec=mpeg4:vhq";
*/
// with ffmpeg: // with ffmpeg:
// /*
// System "ffmpeg -hq -r 5 -b 800 -vcodec mpeg1video System "ffmpeg -hq -r 5 -b 800 -vcodec mpeg1video
// -i t8-%02d.jpg t8.mpg" -i t8-%02d.jpg t8.mpg"
// System "ffmpeg -hq -r 5 -b 800 -i t8-%02d.jpg t8.asf" System "ffmpeg -hq -r 5 -b 800 -i t8-%02d.jpg t8.asf"
*/
EndIf EndIf
EndFor EndFor
#
# parameter file for mpeg_encode
#
PATTERN I
# PATTERN IB
# PATTERN IBBBP
# PATTERN IBBPBBPBBPBBPBB
BASE_FILE_FORMAT JPEG
# BASE_FILE_FORMAT PPM
# BASE_FILE_FORMAT YUV
# YUV_SIZE 320x240
GOP_SIZE 1
# GOP_SIZE 30
SLICES_PER_FRAME 1
PIXEL HALF
RANGE 10
PSEARCH_ALG TWOLEVEL
# PSEARCH_ALG LOGARITHMIC
BSEARCH_ALG CROSS2
IQSCALE 1
# IQSCALE 8
PQSCALE 10
BQSCALE 25
REFERENCE_FRAME DECODED
# REFERENCE_FRAME ORIGINAL
OUTPUT t8.mpg
INPUT_CONVERT *
INPUT_DIR .
INPUT
t8-*.jpg [01-50]
# t8-*.ppm [01-50]
# t8-*.yuv [01-50]
END_INPUT
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment