Copy link to clipboard
Copied
After working on scripts for AE, I'm trying to get things going in Premiere.
However, the documentation here lacks severely, and finding the right functions isn't a walk in the park either. So I wanted to check if these two things are possible before I try to delve deeper:
Bruce Bullis -- could you please shed a light on my questions?
Thanks in advance!
After testing my script, there is a strange anomaly.
I have a sequence with split (extended) markers that show a range inside the sequence.
When I run this script:
...
var activeSequence = app.project.activeSequence;
if (activeSequence) {
var markers = activeSequence.markers;
if (markers) {
var numMarkers = markers.numMarkers;
if (numMarkers > 0) {
var marker_index = 1;
for(var current_marker = markers.getFirstMarker();
current_marker !== undefined;
current_marker = markers.getNextMarker(current_marker)){
Copy link to clipboard
Copied
Ok, to answer my own question - and creating a new question:
Yes, it's possible - by iterating through the markers and setting the inPoint and outPoint.
However, I cannot seem to get the encoding of the "workarea" (set by the in/out range) working:
app.project.activeSequence.setInPoint(1);
$.writeln("In:"+app.project.activeSequence.getInPoint());
app.project.activeSequence.setOutPoint(5);
$.writeln("Out:"+app.project.activeSequence.getOutPoint());
app.encoder.encodeSequence(app.project.activeSequence,"output.mp4", "preset.epr", app.encoder.ENCODE_WORKAREA, 1);
The sequence is 11 seconds long, I select from 1 - 5 seconds, put it the renderqueue and render with ENCODE_WORKAREA -- it always renders 11 seconds for me.
Bruce Bullis​ -- is there a problem with this approach?
Copy link to clipboard
Copied
And the last piece of the puzzle is now ready:
There are three different parameters when encoding:
So this works fine, when iterating through the markers, setting the in/out points, and rendering out with the correct parameter:
app.project.activeSequence.setInPoint(1);
$.writeln("In:"+app.project.activeSequence.getInPoint());
app.project.activeSequence.setOutPoint(5);
$.writeln("Out:"+app.project.activeSequence.getOutPoint());
app.encoder.encodeSequence(app.project.activeSequence,"output.mp4", "preset.epr", app.encoder.ENCODE_IN_TO_OUT, 1);
Copy link to clipboard
Copied
After testing my script, there is a strange anomaly.
I have a sequence with split (extended) markers that show a range inside the sequence.
When I run this script:
var activeSequence = app.project.activeSequence;
if (activeSequence) {
var markers = activeSequence.markers;
if (markers) {
var numMarkers = markers.numMarkers;
if (numMarkers > 0) {
var marker_index = 1;
for(var current_marker = markers.getFirstMarker();
current_marker !== undefined;
current_marker = markers.getNextMarker(current_marker)){
var selectIn = current_marker.start.seconds;
app.project.activeSequence.setInPoint(selectIn);
var getIn = app.project.activeSequence.getInPoint();
$.writeln("In: "+marker_index+" -> "+getIn);
var selectOut = current_marker.end.seconds;
app.project.activeSequence.setOutPoint(selectOut);
var getOut = app.project.activeSequence.getOutPoint();
$.writeln("Out: "+marker_index+" -> "+getOut);
app.encoder.encodeSequence(app.project.activeSequence,"test-"+marker_index+".mp4",
"preset.epr", app.encoder.ENCODE_IN_TO_OUT, 1);
alert();
}
}
}
}
All is fine - the encoder fires up, adds the sequence to it, shows me an alert - and after I click it it goes through all the sequences - and exports the correct ranges perfectly.
When I comment the alert(); -- I runs through all the markers, and adds them to the queue all using the same in/out point.
It seems like when the alert fires, the window is brought to the front and the selection is done correctly - but when it's done in the background there is something going wrong.
Bruce Bullis​ -- is this a bug? Or is there another way to do this more efficiently?
Copy link to clipboard
Copied
The "if I remove the alert" behavior sounds like an AME bug; I'm not sure you're going to get useful behavior out of your "current_marker =" line.
Specifically, it seems like you're relying on a JavaScript-y practice of declaring a function as the handler for the result of another (in this case, getNextMarker() hopefully returns a marker; no function handler will be invoked upon return. [I may be reading too much into it, but that second paren (search for "current_marker))") raises suspicions.
Copy link to clipboard
Copied
To your first question(s): Yes, you can set in/outs, for items open in the source monitor, and yes, you can use encodeSequence() to render sequences in AME; you can use transcode() to render individual files, and yes, you can specify in/out points for those files.
Copy link to clipboard
Copied
Yes, indeed that sounds like a bug. Where do I file bugs? Or is this being forwarded by you to the development team?
Using exportAsMediaDirect, it works perfectly. So I have a backup for this problem right now.
Thanks for the tips on the functions!
Copy link to clipboard
Copied
Hello SWAX,
Can you please post an example of using exportAsMediaDirect?
Copy link to clipboard
Copied
Here's some exportAsMediaDirect() sample usage, in case you don't want editors to get back to work as fast as they can, if you render in AME.
Samples/Premiere.jsx at master · Adobe-CEP/Samples · GitHub
Copy link to clipboard
Copied
Thanks Bruce.
I have used the following functions for a simple Sequence IN/OUT sending to Encoder.
app.encoder.launchEncoder();
app.encoder.encodeSequence()
The Encoder launched properly, but the jobs are not being adding to Encoder queue.
Copy link to clipboard
Copied
Looks like its a bug as SWAX pointed.
Without Alert, its writing the same IN/OUT points.
Some kind of CLEAR function is needed. Or does it exist?
Copy link to clipboard
Copied
I understand what you mean. I have seen other things happen too fast when alert() is not part of the script. This is my first attempt at getting Premiere to work with Media Encoder with a script. When I run your script with alerts firing I don't see anything happen to Media Encoder. The Exstend Script TooIkit give me back the long string saying the encoder commands were successful. I have tried having Media Encoder open and closed. Is there some of steps that have to be done to Media Encoder to get this to work? Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now