# AME Scripting Guide¶

This is a community-created and -maintained project documenting Extendscript usage for Adobe Media Encoder.

## How do I run scripts in AME?¶

Similarly to Premiere Pro, you can use Visual Studio Code and the “ExtendScript Debugger” extension to send scripts from VS Code to AME and debug them in the app. Open the script, select the target and run or debug the script.

You can also launch scripts from the command line on Mac and Windows, like this

<fullPathToAMEbinary> --console es.processFile <fullPathToScript>


Example for executing a test script on Mac:

"/Applications/Adobe Media Encoder (Beta)/Adobe Media Encoder (Beta).app/
--console es.processFile ~/Desktop/test.js


## What is a good starting point to understand the scripting objects?¶

// make sure to replace "\\" by "/" on Mac with a valid path
var source = "D:\\full\\path\\to\\camera3.mxf";
var preset = "D:\\full\\path\\to\\AME\\MediaIO\\systempresets\\58444341_4d584658\\XDCAMHD 50 PAL 50i.epr";
var destination = "C:\\full\\path\\to\\Output\\test";

var exporter = app.getExporter();

if (exporter) {
var encoderWrapper  = exporter.exportItem(source, destination, preset);

// We can get the encoding status from the event or from the exporter
$.writeln("Encode Complete Status: " + eventObj.encodeCompleteStatus); var encodeSuccess = exporter.encodeSuccess;$.writeln("Encode Complete Status alt: " + encodeSuccess);
}, false)

// We can get the encoding status from the event or from the exporter
$.writeln("Error while encoding"); var encodeSuccess = exporter.encodeSuccess;$.writeln("Encode Complete Status: " + encodeSuccess);
}, false)

}


In order to encode a source file in AME, you need to provide the paths of the source file and destination folder, and the preset to be used.

The event listener for onEncodeComplete will be called once the encode has successfully finished.