This is an old revision of the document!
From the 2.1 branch on, Avidemux uses the SpiderMonkey ECMAScript language to handle scripting. Project files are based on ECMAScript.
You can use ECMAScript to do your custom scripts. This documentation will present Avidemux commands.
The first thing to take care of is that an Avidemux ECMAScript project must start with “//AD”. For example, like this:
//AD //--automatically built-- //--Project: /tmp/l.js var app = new Avidemux();
You will probably want to create an instance of the Avidemux class, that will give you access to Avidemux internal functions.
This is done by the new Avidemux() command, you will note that in all examples, the instance is refered to as “app”.
Warning: most non integer parameters must be sent double quoted.
It is generally a good idea to save a project file and use it as a starting point for your custom scripts.
After you have the standard head of your script, as explained in the previous section, you then call all of the functions with a '.' after the variable name you declared. For example, with the line var(nbsp)app(nbsp)=(nbsp)new(nbsp)Avidemux();, you would use app.function where function is the name of the function you want. For list of available functions, see other sections of this article.
Some example function calls:
Here is the set of commands which are not part of the Avidemux class. They can be accessed directly.
|displayError||string||Display an error popup with the message|
|displayInfo||string||Display an info popup with the message|
|fileReadSelect||filename||Open the file selector (read)|
|fileWriteSelect||filename||Open the file selector (write)|
|allFilesFrom||directory||Number of files from that directory||Initiate the directory parsing|
|nextFile||filename||Returns the next filename|
|load||“filename”||Load the video (erasing all)|
|append||“filename”||Append the video to the existing video(s)|
|save||“filename”||Save output to the given filename|
|saveDVD||“filename”||Set output format to MPEG PS and save|
|saveOGM||“filename”||Set output format to OGM and save|
|clearSegments||Remove all segments, after that command you have 0 frames available!|
|addSegment||reference||start,len||Add a new segment from the source reference, starting at frame start with len frames|
|goToTime||hh||mm,ss||Go to frame at hh hour, mm minutes and ss seconds|
|forceUnpack||Set autounpack, you must call it before loading a file, and it will be unpacked|
|setContainer||“container”||Set the output container (must be between “”) - available choices are PS, ES, TS, OGM, AVI, AVI_DUAL, AVI_UNP|
There are also a couple of variables you may want to change:
|addFilter||“filter name”||“filter param”||Add the filter|
|clearFilters||Removes all video filters|
|Codec||“codec name”||"codec conf"[,"codec extra"]||Select the encoder, using the conf, which can be “CBR=bitrate”, “CQ=qz”, “2PASS=size” or “SAME=0”|
|saveJpeg||“filename”||Save the current frame as a JPEG file|
|getWidth||integer||Returns video width|
|getHeight||integer||Returns video height|
|getFps1000||integer||Returns the video framerate * 1000|
|setFps1000||integer||set the video framerate * 1000|
|getFCC||string||returns video FourCC as a string|
|isVopPacked||integer||Returns if video has packed bitstream or not|
|hasQpel||integer||Returns if video has Qpel or not|
|hasGmc||integer||Returns if video has GMC or not|
|scanVBR||Build the time map needed for MP3 VBR|
|save||“filename”||Save the audio track as filename|
|load||“type”||“filename”||Load audio as an external track, type is the file type - AC3, MP3, WAV, filename is the name of the file to load|
|getNbTracks||integer||Returns the number of audio tracks at frame frame|
|setTrack||track||Select track “track”|
There are also a couple of variables you may want to change as above, if your instance has been created by app=new(nbsp)Avidemux(). You will access them using app.audio.xxx=yyy: