Skip to main content
tompfeifle
New Participant
March 13, 2018
Answered

Premiere to media encoder with extendscript

  • March 13, 2018
  • 1 reply
  • 1905 views

Hi Guys,

Since I'm new to extendscript, I'm still having some trouble with it, maybe you guys can help. I have a sequence with a lot of short clips in it and I want to export the clips separately. Up till now I've always nested all the clips after editing them and then exported the nested sequences. But since it's for a recurring client, I've been trying to automate this proces with a script to make it easier.

What I'm doing: I made a script that sets the in/out point of the sequence and sends it to media encoder. It iterates through all the clips in the sequence and does this for every one of them, so essentially I'm exporting the same sequence, but with different in/out points. Everything appears to work just fine, I get a bunch of clips in my render queue with the right names. The problem is, that the in/out point for every clip is the same.

This is what I got so far:

app.enableQE();

var actSeq = app.project.activeSequence;

if (actSeq) {

    var seqName = actSeq.name;

    var actTrack = actSeq.videoTracks[0];

    var clipCount = actTrack.clips.numItems;

    //app.encoder.launchEncoder();   

    var outPreset = new File(outputPresetPath);

    var outputPresetPath = "~/Documents/Adobe/Adobe%20Media%20Encoder/12.0/Presets/480x270%2016-9%20LowRes.epr";

    var outputPath = Folder.selectDialog("Kies Export Folder");

    var activeSequence = qe.project.getActiveSequence();

    var i;

    for (i=0; i<clipCount; i++){

        var actClip = actTrack.clips;

        var clipInPoint = actClip.start;

        var clipOutPoint = actClip.end;

        actSeq.setInPoint(clipInPoint);

        actSeq.setOutPoint(clipOutPoint);

        var clipName = actClip.name.split(".").shift();

        var outputFormatExtension = activeSequence.getExportFileExtension(outPreset.fsName);

        var fullPathToFile = outputPath.fsName + "/" + clipName + "." + outputFormatExtension;

        var outFileTest = new File(fullPathToFile);   

        var jobID = app.encoder.encodeSequence(actSeq,  fullPathToFile, outPreset.fsName, 1, 1);

    };

    outPreset.close();

} else {

    alert("Geen actieve sequence. Selecteer er eerst één.")

    }

I can't figure out why it's going wrong, since everything else is working correctly.

Thanks!

[EDIT] BTW: if I iterate manually, by just changing the i variable into a number, it works perfectly fine.

This topic has been closed for replies.
Correct answer tompfeifle

Weird, I tried this yesterday, since I tried just about everything. I did not work then, but now it partially works. The only problem is, it's shifting the in/out points for the clips. All the clips in the render queue are getting different i/o points now, but the 1st clip is getting the i/o points of the 2nd clip, the 2nd clip those of the 3rd clip, etc. So the last 2 clips have the same i/o points.

We're a little closer, but still not there.


I might have found it:

Earlier I added app.project.save() right before the encodeSequence() line. That gave me the problem I described above. But I just moved the save() line to just AFTER the encodeSequence(). That seems to have fixed it, but I'll have to give it a test run to be sure.

Thanks for your help so far.

1 reply

Bruce Bullis
Community Manager
Community Manager
March 14, 2018

> ...the in/out point for every clip is the same.

Is that same range one set of in/out points, or is it 'entire clip'? [I'm trying to figure out whether AME is honoring the in/out points once, or never.]

tompfeifle
New Participant
March 14, 2018

Hey Bruce,

Thanks for the reply. Yes, it's getting the in/out points from the start/end properties from the clips. But every clip in AME has the in/out point from the last clip in the sequence. So if I have 15 clips in the premiere sequence, AME fills the queue with the 15th clip 15 times.

tompfeifle
New Participant
March 14, 2018

Something to try (while I dig into the history on this): If you save the project between each call to encodeSequence(), do the right in/out points get sent?

Hypothesis: the sequence is getting submitted to the render queue, with 'stale' in/out information.


Weird, I tried this yesterday, since I tried just about everything. I did not work then, but now it partially works. The only problem is, it's shifting the in/out points for the clips. All the clips in the render queue are getting different i/o points now, but the 1st clip is getting the i/o points of the 2nd clip, the 2nd clip those of the 3rd clip, etc. So the last 2 clips have the same i/o points.

We're a little closer, but still not there.