Copy link to clipboard
Copied
Hi,
I'm trying to find a way to add a track in a sequence with a script. (as the last commands from the menu list "sequences", add or delete tracks).
Fab.
There's no function for adding (or removing) tracks, in the PPro ExtendScript DOM.
Perhaps you could create a new sequence from a template?
Hey Bruce,
thanks for your reply 🙂
The problem was, that using the remove functions with QEDom was causing an audioTrack to be deleted, which was not empty.
I am not really sure why this happened, but after cleaning up my code a little the problem did not seem to occur anymore.
In this case, I am sending commands to AfterEffects via BridgeTalk, because I thought we do not need an extra AE-panel for the usecase.
This works pretty neat, but I forgot some simple things, like "do not import footage if
...Copy link to clipboard
Copied
To add Tracks in a Sequence, right-click in the empty area of your Timeline and choose Add Tracks...
Copy link to clipboard
Copied
And then in the dialogue box choose whether you want to add Video or Audio tracks and how many.
Copy link to clipboard
Copied
You either use the dropdown menu or rightclick on the HEADER in the timeline or set up KBSC.
Copy link to clipboard
Copied
hum hum, sorry it was obvious to me with the title of my post... I want to do this in a script, with extendscript.
Copy link to clipboard
Copied
Yeah got it now. Added SDK to your post for better help.
Copy link to clipboard
Copied
app.enableQE();
var seq = qe.project.getActiveSequence();
Then you will have access to:
addTracks()
removeTracks()
removeVideoTrack()
removeAudioTrack()
removeEmptyVideoTracks()
removeEmptyAudioTracks()
No documentation on QE. Just kinda got test things out.
Might also help to know that you target tracks by using:
seq.getVideoTrackAt(x);
Copy link to clipboard
Copied
Is there a way to get a specific sequence with the qe dom rather than just the active sequence?
for (var i = 0; i < qe.project.sequences.numSequences; i++) {
var seq = qe.project.sequences[i];
if (seq.sequenceID === newSeqID){
var newSeq = seq;
}
}
This works:
for (var i = 0; i < app.project.sequences.numSequences; i++) {
var seq = app.project.sequences[i];
if (seq.sequenceID === newSeqID){
var newSeq = seq;
}
}
Copy link to clipboard
Copied
Is there a way to get a specific sequence with the qe dom rather than just the active sequence?
This might help when trying to find a sequence by id:
var removeEmptyAudioAndVideoTracksInVersionSequence = function removeEmptyAudioAndVideoTracksInVersionSequence(sequenceId) {
app.enableQE();
var bin = getBinFromQEDomByPath('mybin/sequences');
if (bin) {
bin.flushCache();
for (var index = 0; index < bin.numSequences; index++) {
sequence = bin.getSequenceAt(index);
if (sequence && sequence.guid === sequenceId) {
sequence.removeEmptyAudioTracks();
sequence.removeEmptyVideoTracks();
return 'true';
}
}
}
return 'error: bin not found!';
};
var getBinFromQEDomByPath = function getBinFromQEDomByPath(binPath) {
app.enableQE();
var qeProject = qe.project;
// remove last char if it is a slash
binPath = binPath.replace(/\/$/, '');
var binPathAsArray = binPath.split('/');
// start at root level
var bin = qeProject;
// go as deep as the binPath is
for (var binNameIndex = 0; binNameIndex < binPathAsArray.length; binNameIndex++) {
for (var currentBinIndex = 0; currentBinIndex < bin.numBins; currentBinIndex++) {
var binToFind = bin.getBinAt(currentBinIndex);
if (binToFind.name === binPathAsArray[binNameIndex]) {
// return it because it is the last bin of the path from binPath
if (binNameIndex === binPathAsArray.length - 1) {
return binToFind;
}
// it was the next bin of the path from binPath
bin = binToFind;
// stop inner loop, continue with outer loop...
break;
}
}
}
// not found
return null;
};
I still have a sporadic problem, that sometimes audioTracks are removed by ``removeEmptyAudioTracks()`` which are not empty 😞
Can anyone confirm this?
(at least in Windows, PPRO 2019 - did not test with other versions yet...)
Copy link to clipboard
Copied
Sorry, just found https://community.adobe.com/t5/premiere-pro-discussions/get-specific-sequence-with-qe-dom-extendscri... after I wrote that...
Copy link to clipboard
Copied
This works, however, is there a way I can decide where the tracks will be created? I wish it to be on top of others
Copy link to clipboard
Copied
There's no function for adding (or removing) tracks, in the PPro ExtendScript DOM.
Perhaps you could create a new sequence from a template?
Copy link to clipboard
Copied
Hey Bruce,
thanks for your reply 🙂
The problem was, that using the remove functions with QEDom was causing an audioTrack to be deleted, which was not empty.
I am not really sure why this happened, but after cleaning up my code a little the problem did not seem to occur anymore.
In this case, I am sending commands to AfterEffects via BridgeTalk, because I thought we do not need an extra AE-panel for the usecase.
This works pretty neat, but I forgot some simple things, like "do not import footage if it already exists" - or "do not insert footage to a layer if it is already in there"....
So after cleaning up it seems to be good.
I must emphasize that I did not try that on newer versions, as we are still stuck to the 2019 versions (PPRO & AEFT), and I also did not try on Mac yet (I test stuff on the Mac after it is running in Windows 😉 ).
I will keep an eye on the remove functions (I know it is not part of the officially supported API), and test stuff in newer CC versions in the future...
(To me, Eli_Portell-TUVs1qs answer seems already correct to the OP question - I just wanted to add some little more detailed code how to get a sequence if you do not want to work with the currently active one, and after I posted it I saw the other post by RajinderSingh where he made a separate post with his question, because it is kind of a different question than the one which was asked here...).