Scripting
1.Foreword
In some case, you end up doing often the same kind of actions to videos. For example, applying always the same filter(s) to a captured movie. On the other hand, you can be tempted to try different settings to see the effect. In both cases, using the nice UI from avidemux does not make things easier.
Some commands are available throught command line, but that's not the easiest way.
There is an ongoing work for scripting capabilities. It means having a simple script language that you can
execute to perform actions unmanned.
The objective at the end, is to be able to do everything through the script language, but we are far from it.
2.Script
A script is a simple text file. It has a syntax near C language, but much more simpler.
You can access it using either file->run script, or using the --run command from cli.
A ligne beginning by either // or # is ignored (you can make script executable and invoke avidemux that way :)
A script is a sequence of function call. A function call is function(param1,param2....);
A parameter can be a integer, a float, true/false or a string. For string, you can also use quoted string for filename ("my file.avi").
The script is parsed one time to check for grammar or syntax error, then executed. If a command fails, the script stops.
3.Commands
Here is the set of command available as of now. To get a list, do avidemux2 --list
File command |
Parameter |
Parameter |
Parameter |
Description |
Load |
filename |
|
|
Load the file given as parameter |
Append |
filename |
|
|
Append a file (does not work) |
LoadAudio |
type |
filename |
|
Load the file as external audio. The first argument is the type : mp3, ac3, wav |
Process command |
Parameter |
Parameter |
Parameter |
Description |
videoprocess |
true/false |
|
|
Set video process mode to on(process) or off (copy) |
audioprocess |
true/false |
|
|
Same for audio |
Save command |
Parameter |
Parameter |
Parameter |
Description |
save |
Filename |
|
|
Save the file |
savejpg |
Filename |
|
|
Save the current image as jpeg |
saveaudio |
Filename |
|
|
Save audio track to the file given |
savedvd |
Filename |
|
|
Save as save DVD PS, i.e. a dvd compatible program stream |
scanvbr |
|
|
|
Build the audio time map, to be able to deal with vbr mp3 |
saveraw |
Filename |
|
|
Save the raw video stream, useful to cut a mpeg for example |
Audio filter |
Parameter |
Parameter |
Parameter |
Description |
normalize |
true/false |
|
|
Set the normalize filter on/off |
downsample |
true/false |
|
|
Set the 48 to 44.1 khz filter on/off |
resample |
targetfrequency |
|
|
Resample to targetfrequency. Passing 0 means disabling the filter |
delay |
delay in ms |
|
|
Apply a delay to audio (also in copy mode). Passing 0 disables the filter |
film2pal |
true/false |
|
|
Set the film2pal audio filter on or off |
Codecs |
Parameter |
Parameter |
Parameter |
Description |
audiocodec |
codec name |
bitrate in kbps |
|
Select the audio codec, can be lame,mp2,ac3,toolame,none |
videocodec |
codec name |
Mode |
optional: codec conf file |
Select the video codec, can be xvid4,ffv1, h263...The mode is cq=qz, or cbr=bitrate in kbps, or 2pass=size in megabytes. Optionnaly, the third argument can be a file containing fine settings for the codec |
Video filters |
Parameter |
Parameter |
Parameter |
Description |
loadfilter |
filename |
|
|
Load the xml file describing the list of video filters. |
Misc |
Parameter |
Parameter |
Parameter |
Description |
setfps |
float |
|
|
Change the frame per second of the movie |
exit |
|
|
|
Exit immediately |
sleep |
integer |
|
|
wait N seconds |
goto |
integer |
|
|
Go to frame number N |
setmarkerA |
integer |
|
|
Set the start marker on given frame |
setmarkerB |
integer |
|
|
Set the end marker on given frame |
4.Examples
The fist example just navigate in a file
Code listing .1 |
Load("/work/samples/2mn.avi");
AudioProcess(1);
videoProcess(1);
sleep(500);
goto(0);
sleep(500);
goto(10);
sleep(500);
goto(20);
sleep(500);
goto(30);
sleep(500);
goto(40);
sleep(500);
# comment
exit();
|
The second example encode a file and set video.
Code listing .2 |
Load("/work/samples/2mn.avi");
videoprocess(on);
//videocodec(xvid4,cq=5);
loadfilter("/home/fx/ep1_b.edl.flt");
videocodec(xvid4,2pass=12,"/home/fx/ep1_b.edl.flt.vcodec");
save("/tmp/plop.avi");
exit();
|
The third example re-encodes a file using xvid and a video filter and letting audio unchanged
Code listing .3 |
Load("ghost1_raw.avi");
AddVideoFilter(mphqdenoise3d,param1=4.000000,param2=3.000000,param3=6.000000);
SetFormat("AVI");
VideoProcess(1);
videocodec(XVID4,"2pass=180","/huge/ghost/dummy.prh.vcodec");
save("flt_1.avi");
|
You will notice we reuse a video codec configuration from a project file. It allows you to
fine tune a codec.
|