Skip to content

Instantly share code, notes, and snippets.

View justintaylor-dev's full-sized avatar
🚀

Justin Taylor justintaylor-dev

🚀
View GitHub Profile
// Registers all possible keystrokes for Adobe CEP panels on Windows and Mac
function keyRegisterOverride() {
var os = navigator.platform.substr(0, 3);
var maxKey;
if (os === 'Mac') {
maxKey = 126; // Mac Max Key Codes
}
else if (os === 'Win') {
maxKey = 222; // HTML Max Key Codes
}
@justintaylor-dev
justintaylor-dev / get-item-metadata.jsx
Created August 29, 2019 16:55
Get Item Metadata #code_ppro
function getPrMetadata(projectItem, fieldNames) {
var kPProPrivateProjectMetadataURI ="http://ns.adobe.com/premierePrivateProjectMetaData/1.0/";
if (app.isDocumentOpen()) {
if (projectItem) {
if (ExternalObject.AdobeXMPScript === undefined)
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
if (ExternalObject.AdobeXMPScript !== undefined) {
var retArray = [];
var retArray2 = [];
var projectMetadata = projectItem.getProjectMetadata();
@justintaylor-dev
justintaylor-dev / add-clips-at-timecode.jsx
Created August 28, 2019 22:05
Add Clips at Timecode #code_ppro
// Adds clips selected in Project Panel to active sequence at their timecode and trims the start of the sequence so timecode is aligned
var viewIDs = app.getProjectViewIDs();
var firstClipTime = null;
var clips = [];
// Loop through and identify all selected items
for (var a = 0; a < app.projects.numProjects; a++) {
var currentProject = app.getProjectFromViewID(viewIDs[a]);
if (currentProject) {
@justintaylor-dev
justintaylor-dev / toggle-difference.jsx
Created July 29, 2019 22:06
Toggle-Difference #code_ppro
// Toggles transfer mode between Difference and Normal
var DIFFERENCE = 5;
var NORMAL = 18;
var selection = app.project.activeSequence.getSelection();
try {
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
if(item.mediaType == 'Video'){
var prop = item.components[0].properties[1];
if(prop.getValue() === DIFFERENCE){
@justintaylor-dev
justintaylor-dev / loop-through-selected-clips.jsx
Created July 26, 2019 22:43
Loop Through Selected Clips #code_ppro
var sequence = app.project.activeSequence,
trackGroups = [sequence.audioTracks, sequence.videoTracks];
for (i = 0; i < trackGroups.length; i++) {
var trackCount = trackGroups[i].numTracks;
for (j = 0; j < trackCount; j++) {
var clipCount = trackGroups[i][j].clips.numItems;
for (k = 0; k < clipCount; k++) {
var clip = trackGroups[i][j].clips[k];
if (clip.isSelected()) {
// do stuff with clip.name
@justintaylor-dev
justintaylor-dev / set-premiere-metadata.jsx
Last active September 9, 2024 19:16
Set Metadata #code_ppro
function setPrMetadata(projectItem, metadata) {
var kPProPrivateProjectMetadataURI = "http://ns.adobe.com/premierePrivateProjectMetaData/1.0/";
if (app.isDocumentOpen() && projectItem) {
if (ExternalObject.AdobeXMPScript === undefined)
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
if (ExternalObject.AdobeXMPScript !== undefined) {
var projectMetadata = projectItem.getProjectMetadata();
var xmp = new XMPMeta(projectMetadata);
for (var pc = 0; pc < metadata.length; pc++) {
var successfullyAdded = app.project.addPropertyToProjectMetadataSchema(metadata[pc][0], metadata[pc][1], 2);
@justintaylor-dev
justintaylor-dev / ease-all-keyframes.jsx
Created July 2, 2019 16:48
ease-all-keyframes #code_aeft
// Gets all properties with keyframes in a layer
function getPropsWithKeys(layer) {
var numRootProps = layer.numProperties;
var propsWithKeys = [];
for (var i = 0; i < numRootProps; i++) {
var prop = layer(i + 1);
var isGroup = prop.numProperties && prop.numProperties > 0;
if (isGroup) {
for (var j = 0; j < prop.numProperties; j++) {
var subProp = prop.property(j + 1);
@justintaylor-dev
justintaylor-dev / get-parent-bin.jsx
Created June 28, 2019 16:10
Get Parent Bin #code_ppro
// Gets the parent bin of a project item
// Example: getParentBin(app.project.activeSequence.projectItem, app.project.rootItem)
function getParentBin(item, base){
var path = item.treePath;
for(var i = 0; i < base.children.numItems; i++){
if(base.children[i].type == ProjectItemType.BIN){
var foundItem = getParent(item, base.children[i]);
if(foundItem){
return foundItem;
@justintaylor-dev
justintaylor-dev / warp-stabilize-selection.jsx
Last active November 1, 2022 18:24
Warp Stabilize Selection #code_aeft
// Apply Warp Stabilizer to first layer in all selected comps
for (i = 0; i < app.project.selection.length; i++) {
app.project.selection[i].layers[1].Effects.addProperty('Warp Stabilizer');
}
@justintaylor-dev
justintaylor-dev / red-log.js
Last active June 27, 2019 18:34
RED Log #code_ppro
// Sets colorspace of selected footage to REDLogFilm
for (var selection, viewIDs = app.getProjectViewIDs(), i = 0; i < viewIDs.length; i++)
if (app.getProjectFromViewID(viewIDs[i]).name == app.project.name) {
selection = app.getProjectViewSelection(viewIDs[i]);
break
}
for (i = 0; i < selection.length;i++){
var item = selection[i];
// item.videoComponents[0].properties[25].setValue(1); // set to REDgamma3