Skip to content

Commit 7586b85

Browse files
committed
Consolidate EncoderHostScript object events
1 parent 6ad4cdd commit 7586b85

File tree

2 files changed

+228
-150
lines changed

2 files changed

+228
-150
lines changed

docs/events/EncoderHostWrapperEvent.md

Lines changed: 0 additions & 150 deletions
This file was deleted.

docs/reference/EncoderHostScript.md

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,231 @@ if (encoderHost) {
252252
$.writeln("encoderHost script object not defined");
253253
}
254254
```
255+
256+
---
257+
258+
## Events
259+
260+
Provides the following event types for items in the batch queue:
261+
262+
- [onItemEncodingStarted](#onitemencodingstarted)
263+
- [onAudioPreEncodeProgress](#onaudiopreencodeprogress)
264+
- [onEncodingItemProgressUpdate](#onencodingitemprogressupdate)
265+
- [onItemEncodeComplete](#onitemencodecomplete)
266+
267+
For multiple batch items in the queue we recommend to use this event to ensure that the event types will be received for all batch items.
268+
269+
It provides the following event type for the whole batch queue:
270+
271+
- [onBatchEncoderStatusChanged](#onbatchencoderstatuschanged)
272+
273+
### Example
274+
275+
```javascript
276+
// Please use this event when you have multiple batch items in the queue (added manually or via a script as below)
277+
// to ensure you receive all event types
278+
var source_1 = "C:\\testdata\\testmedia1.mxf";
279+
var source_2 = "C:\\testdata\\testmedia2.mxf";
280+
var source_3 = "C:\\testdata\\testmedia3.mxf";
281+
282+
// //sources for mac
283+
// var source_1 = "/Users/Shared/testdata/testmedia1.mxf"
284+
// var source_2 = "/Users/Shared/testdata/testmedia2.mxf";
285+
// var source_3 = "/Users/Shared/testdata/testmedia3.mxf";
286+
287+
var frontend = app.getFrontend();
288+
if (frontend) {
289+
// listen for batch item added event
290+
frontend.addEventListener("onItemAddedToBatch", function (eventObj) {
291+
$.writeln("frontend.onItemAddedToBatch: success");
292+
});
293+
294+
var batchItemSuccess_1 = frontend.addItemToBatch(source_1);
295+
var batchItemSuccess_2 = frontend.addItemToBatch(source_2);
296+
var batchItemSuccess_3 = frontend.addItemToBatch(source_3);
297+
if (batchItemSuccess_1 && batchItemSuccess_2 && batchItemSuccess_3) {
298+
$.writeln(
299+
"Batch item added successfully for the source files ",
300+
source_1 + " , " + source_2 + " , " + source_3
301+
);
302+
303+
encoderHost = app.getEncoderHost();
304+
if (encoderHost) {
305+
// listen to the item encoding started event (available since 23.1.)
306+
encoderHost.addEventListener(
307+
"onItemEncodingStarted",
308+
function (eventObj) {
309+
$.writeln(
310+
"onItemEncodingStarted: Source File Path: " +
311+
eventObj.sourceFilePath
312+
);
313+
$.writeln(
314+
"onItemEncodingStarted: Output File Path: " +
315+
eventObj.outputFilePath
316+
);
317+
}
318+
);
319+
320+
/* for earlier versions (23.0. or older) there's an additional step necessary to listen to the onItemEncodingStarted event
321+
var exporter = app.getExporter();
322+
if (exporter) {
323+
exporter.addEventListener(
324+
"onItemEncodingStarted",
325+
function (eventObj) {
326+
$.writeln("onItemEncodingStarted");
327+
}
328+
);
329+
}
330+
*/
331+
332+
// listen to the item encoding progress event (available since 23.1.)
333+
encoderHost.addEventListener(
334+
"onEncodingItemProgressUpdate",
335+
function (eventObj) {
336+
$.writeln(
337+
"onEncodingItemProgessUpdate: Encoding Progress: " +
338+
eventObj.progress
339+
);
340+
}
341+
);
342+
343+
// listen to the audio pre-encoding progress event (available since 24.0.)
344+
encoderHost.addEventListener(
345+
"onAudioPreEncodeProgress",
346+
function (eventObj) {
347+
$.writeln("Audio pre-encoding info: " + eventObj.audioInfo);
348+
$.writeln("Audio pre-encoding progress: " + eventObj.audioProgress);
349+
},
350+
false
351+
);
352+
353+
/* for earlier versions (23.0. or older) there's an additional step necessary to listen to the onEncodingItemProgressUpdated event
354+
var exporter = app.getExporter();
355+
if (exporter) {
356+
exporter.addEventListener(
357+
"onEncodingItemProgressUpdated",
358+
function (eventObj) {
359+
$.writeln("onEncodingItemProgessUpdated: Encoding Progress: " + eventObj.progress);
360+
}
361+
);
362+
}
363+
*/
364+
365+
// listen to the item encoding complete event
366+
encoderHost.addEventListener("onItemEncodeComplete", function (eventObj) {
367+
$.writeln("onItemEncodeComplete: Result: " + eventObj.result);
368+
$.writeln(
369+
"onItemEncodeComplete: Source File Path: " + eventObj.sourceFilePath
370+
);
371+
$.writeln(
372+
"onItemEncodeComplete: Output File Path: " + eventObj.outputFilePath
373+
);
374+
});
375+
376+
encoderHost.runBatch();
377+
} else {
378+
$.writeln("encoderHost not valid");
379+
}
380+
} else {
381+
$.writeln("batch item wasn't added successfully");
382+
}
383+
} else {
384+
$.writeln("frontend not valid");
385+
}
386+
```
387+
388+
---
389+
390+
### onAudioPreEncodeProgress
391+
392+
`app.getEncoderHost().addEventListener("onAudioPreEncodeProgress")`
393+
394+
!!! note
395+
This functionality was added in Media Encoder 24.0
396+
397+
#### Description
398+
399+
Notify when the audio pre-encode progress changes.
400+
401+
#### Properties
402+
403+
| Property | Type | Description |
404+
| --------------- | ------ | ------------------------------- |
405+
| `audioInfo` | String | The audio pre-encoding info |
406+
| `audioProgress` | Float | The audio pre-encoding progress |
407+
408+
---
409+
410+
### onBatchEncoderStatusChanged
411+
412+
`app.getEncoderHost().addEventListener("onBatchEncoderStatusChanged")`
413+
414+
!!! note
415+
This functionality was added in Media Encoder 23.3
416+
417+
#### Description
418+
419+
Notify when the batch encoder status has changed. Get the new status from the `batchEncoderStatus` property.
420+
421+
#### Properties
422+
423+
| Property | Type | Description |
424+
| -------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
425+
| `batchEncoderStatus` | String | Returns the status of the batch encoder, when the event was sent. The values are:<ul><li>`"invalid"`</li><li>`"paused"`</li><li>`"running"`</li><li>`"stopped"`</li><li>`"stopping"`</li></ul> |
426+
427+
---
428+
429+
### onEncodingItemProgressUpdate
430+
431+
`app.getEncoderHost().addEventListener("onEncodingItemProgressUpdate")`
432+
433+
!!! note
434+
This functionality was added in Media Encoder 23.1
435+
436+
#### Description
437+
438+
Notify of the batch item encoding progress.
439+
440+
#### Properties
441+
442+
| Property | Type | Description |
443+
| ---------- | ----- | ---------------------------------------------- |
444+
| `progress` | Float | Returns the encoding progress between 0 and 1. |
445+
446+
---
447+
448+
### onItemEncodeComplete
449+
450+
`app.getEncoderHost().addEventListener("onItemEncodeComplete")`
451+
452+
#### Description
453+
454+
Notify when the batch item has been encoded.
455+
456+
#### Properties
457+
458+
| Property | Type | Description |
459+
| ---------------- | ------ | ----------------------------------------------- |
460+
| `outputFilePath` | String | Returns the path of the output file. |
461+
| `result` | String | Returns the encoding result, `True` or `False`. |
462+
| `sourceFilePath` | String | Returns the path of the source file. |
463+
464+
---
465+
466+
### onItemEncodingStarted
467+
468+
`app.getEncoderHost().addEventListener("onItemEncodingStarted")`
469+
470+
!!! note
471+
This functionality was added in Media Encoder 23.1
472+
473+
#### Description
474+
475+
Notify when the batch item encoding started.
476+
477+
#### Properties
478+
479+
| Property | Type | Description |
480+
| ---------------- | ------ | ------------------------------------ |
481+
| `outputFilePath` | String | Returns the path of the output file. |
482+
| `sourceFilePath` | String | Returns the path of the source file. |

0 commit comments

Comments
 (0)