Skip to content

Instantly share code, notes, and snippets.

@boredstiff
Created November 6, 2016 16:25
Show Gist options
  • Save boredstiff/a7f6bce9fac30fd543270c446f2e742c to your computer and use it in GitHub Desktop.
Save boredstiff/a7f6bce9fac30fd543270c446f2e742c to your computer and use it in GitHub Desktop.
Render Sequences in Premiere Pro
render : function(outputPresetPath, outputPath) {
app.enableQE();
var activeSequence = qe.project.getActiveSequence();
if (activeSequence) {
app.encoder.launchEncoder();
var timeSecs = activeSequence.CTI.secs;
var timeFrames = activeSequence.CTI.frames;
var timeTicks = activeSequence.CTI.ticks;
var timeString = activeSequence.CTI.timecode;
var seqInPoint = app.project.activeSequence.getInPoint();
var seqOutPoint = app.project.activeSequence.getOutPoint();
var projPath = new File(app.project.path);
if ((outputPath) && projPath.exists){
var outPreset = new File(outputPresetPath);
if (outPreset.exists === true){
var outputFormatExtension = activeSequence.getExportFileExtension(outPreset.fsName);
if (outputFormatExtension){
var outputFilename = activeSequence.name + '.' + outputFormatExtension;
var fullPathToFile = outputPath.fsName +
$._PPP_.getSep() +
activeSequence.name +
"." +
outputFormatExtension;
var outFileTest = new File(fullPathToFile);
if (outFileTest.exists){
var destroyExisting = confirm("A file with that name already exists; overwrite?", false, "Are you sure...?");
if (destroyExisting){
outFileTest.remove();
outFileTest.close();
}
}
app.encoder.bind('onEncoderJobComplete', $._PPP_.onEncoderJobComplete);
app.encoder.bind('onEncoderJobError', $._PPP_.onEncoderJobError);
app.encoder.bind('onEncoderJobProgress', $._PPP_.onEncoderJobProgress);
app.encoder.bind('onEncoderJobQueued', $._PPP_.onEncoderJobQueued);
// use these 0 or 1 settings to disable some/all metadata creation.
app.encoder.setSidecarXMPEnabled(0);
app.encoder.setEmbeddedXMPEnabled(0);
// For reference, here's how to export from within PPro (blocking further user interaction).
// activeSequence.exportAsMediaDirect(fullPathToFile, outPreset.fsName, app.encoder.ENCODE_WORKAREA);
var jobID = app.encoder.encodeSequence( app.project.activeSequence,
fullPathToFile,
outPreset.fsName,
app.encoder.ENCODE_WORKAREA,
1); // Remove from queue upon successful completion?
$._PPP_.message('jobID = ' + jobID);
outPreset.close();
}
} else {
alert("Could not find output preset.");
}
} else {
alert("Could not find/create output path.");
}
projPath.close();
} else {
alert("No active sequence.");
}
}
var rootItem = app.project.rootItem
/* There's no way to query an item's "type" in Premiere - at least there wasn't when I was doing stuff
Put all sequences inside of a bin at the top level of the project called 'Sequences' */
for (var item = 0; item < rootItem.children.numItems; item++) {
if (rootItem.children[item].name === 'Sequences') {
var bin = rootItem.children[item]
for (var s = 0; s < bin.children.numItems; s++) {
var currentSequence = bin.children[s]
// Put one of the render/transcode methods here.
var outputPresetPath = 'path/to/output/preset'
var outputPath = 'path/to/output/folder'
render(outputPresetPath, outputPath)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment