Watch Folder

data-variant=info
data-slots=text
UXP for Adobe Media Encoder is in public beta. This reference is being written, and the supported API surface may change before general availability.

Since: 27.0

The Media Encoder Watch Folder API is the used for all operations involving managing Watch Folders in Media Encoder. A watch folder monitors a source directory and automatically encodes new files using a specified preset.

The Watch Folder object can be acceessed from the main app object:

const app = require("mediaencoder");
const WatchFolder = app.WatchFolder;

Constants

These Watch Folder Constants are used as parameters in various WatchFolder API methods for Media Encoder.

All Constants can be accessed via the WatchFolder object:

const app = require("mediaencoder");
const WatchFolder = app.WatchFolder;
const WATCH_FOLDER_ENCODER_STATUS_CHANGED =
  WatchFolder.WATCH_FOLDER_ENCODER_STATUS_CHANGED; // "AMEProgressCategoryRender"

PROGRESS_CATEGORY_ID

Retrieves the unique identifier for the progress category for global progress of the AME renderer. This ID allows access to the global progress of the AME Renderer. To obtain the category, use getOrCreateProgressCategory() on the ProgressCategoryContainer object. The ProgressItem object should be used to manage individual progress items. Each job item is registered using its unique reference ID.

Type: string

Since: 27.0

WATCH_FOLDER_ENCODER_STATUS_CHANGED

Event ID for when a watch folder encoder status changes.

Type: string

Since: 27.0

Properties

These read-only properties are available on a watch folder object, such as the one returned by createWatchFolder.

const app = require("mediaencoder");
const watchFolder = app.WatchFolder.createWatchFolder(
  "path/to/source",
  "path/to/destination",
  "path/to/preset.epr",
);
watchFolder.id; // "e8105b34-f5f8-4254-84d9-6345120568f4"

id

The unique identifier (GUID) for the watch folder.

Type: string (readonly)

Since: 27.0

filePath

The source path being monitored by the watch folder.

Type: string (readonly)

Since: 27.0

presetPath

The preset file path used for encoding.

Type: string (readonly)

Since: 27.0

destinationPath

The destination path where encoded files are saved.

Type: string (readonly)

Since: 27.0

Methods

getInstance

Gets an instance of the WatchFolder object.

Since: 27.0

Parameters

none

Returns

Name
Type
Description
watchFolder
object
A WatchFolder object
const app = require("mediaencoder");
const watchFolder = app.WatchFolder.getInstance();

createWatchFolder

Creates a watch folder that monitors the source directory and automatically encodes new files using the specified preset. The watch folder will process any new files added to the source directory and save the encoded output to the destination directory.

Since: 27.0

Parameters

Name
Type
Description
sourcePath
string
The path to the folder which should be monitored as a watch folder
destinationPath
string
The path where encoded files will be saved
presetPath
string
The full path to the preset file (*.epr) to use for encoding

Returns

A watch folder item object with the following read-only properties:

Name
Type
Description
id
string
The unique identifier (GUID) for the watch folder
filePath
string
The source path being monitored by the watch folder
presetPath
string
The preset file path used for encoding
destinationPath
string
The destination path where encoded files are saved
const app = require("mediaencoder");
const watchFolder = app.WatchFolder.createWatchFolder(
  "path/to/source",
  "path/to/destination",
  "path/to/preset.epr",
);
watchFolder; // { id, filePath, presetPath, destinationPath }

Throws a parameter error if the source path, destination path, or preset path does not exist or is invalid, or if the preset uses an unsupported HEVC encoding format (when called from a non-first-party context).

getAllWatchFolders

Returns an array of all active watch folder objects.

Since: 27.0

Parameters

none

Returns

Name
Type
Description
watchFolders
object[]
Array of all active watch folder objects
const app = require("mediaencoder");
const watchFolders = app.WatchFolder.getAllWatchFolders();

removeAllWatchFolders

Removes all active watch folders from the system.

Since: 27.0

Parameters

none

Returns

Name
Type
Description
result
boolean
Returns true if removal was successful
const app = require("mediaencoder");
const success = app.WatchFolder.removeAllWatchFolders();
success; // true

addEventListener

Registers an event handler for the specified event on this WatchFolder. The event handling follows the W3C DOM Level 2 Events Specification.

Since: 27.0

Parameters

Name
Type
Description
eventType
string
The event to listen for, such as WATCH_FOLDER_ENCODER_STATUS_CHANGED
handler
function
A function to be triggered when the specified event occurs

Returns

none

const app = require("mediaencoder");
const watchFolder = app.WatchFolder.getInstance();
const event = app.WatchFolder.WATCH_FOLDER_ENCODER_STATUS_CHANGED;
const callback = (statusEvent) => {
  console.log("Watch Folder Encoder Status Changed", statusEvent.status);
};
watchFolder.addEventListener(event, callback);

removeEventListener

Unregisters a previously registered event handler for the specified event on this WatchFolder.

Since: 27.0

Parameters

Name
Type
Description
eventType
string
The event to stop listening for
handler
function
The previously registered callback to remove

Returns

none

const app = require("mediaencoder");
const watchFolder = app.WatchFolder.getInstance();
const event = app.WatchFolder.WATCH_FOLDER_ENCODER_STATUS_CHANGED;
const callback = (statusEvent) => {
  console.log("Watch Folder Encoder Status Changed", statusEvent.status);
};
watchFolder.addEventListener(event, callback);
watchFolder.removeEventListener(event, callback);