Add a track in a sequence, extendscript

New Here ,
Oct 11, 2019 Oct 11, 2019

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.

TOPICS
SDK

Views

1.2K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Participant , Jan 20, 2022 Jan 20, 2022

There's no function for adding (or removing) tracks, in the PPro ExtendScript DOM.

Perhaps you could create a new sequence from a template?

Likes

Translate

Translate
Explorer , Jan 21, 2022 Jan 21, 2022

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

...

Likes

Translate

Translate
Adobe Community Professional ,
Oct 11, 2019 Oct 11, 2019

Copy link to clipboard

Copied

To add Tracks in a Sequence, right-click in the empty area of your Timeline and choose Add Tracks...

Marek Mularczyk
Adobe Certified Expert and Instructor

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 11, 2019 Oct 11, 2019

Copy link to clipboard

Copied

And then in the dialogue box choose whether you want to add Video or Audio tracks and how many.

Marek Mularczyk
Adobe Certified Expert and Instructor

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 11, 2019 Oct 11, 2019

Copy link to clipboard

Copied

You either use the dropdown menu or rightclick on the HEADER in the timeline or set up KBSC.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 11, 2019 Oct 11, 2019

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Oct 11, 2019 Oct 11, 2019

Copy link to clipboard

Copied

Yeah got it now. Added SDK to your post for better help.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 15, 2019 Oct 15, 2019

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);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Is there a way to get a specific sequence with the qe dom rather than just the active sequence? 

app.enableQE();
var seq = qe.project.getActiveSequence();
Then you will have access to: addTracks()

the problem here is im not trying to get the active sequence
 
I am trying to get sequence by a specific ID
 
This fails:

 

	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;
			} 
		}​

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

quote

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...)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2022 Jan 20, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 20, 2022 Jan 20, 2022

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?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 21, 2022 Jan 21, 2022

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...).

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines