• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

2.8K

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

Adobe Employee , 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?

Votes

Translate

Translate
Participant , 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

...

Votes

Translate

Translate
Community Expert ,
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...

Adobe Community Expert
Adobe Certified Professional

Votes

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
Community Expert ,
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.

Adobe Community Expert
Adobe Certified Professional

Votes

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
Community Expert ,
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.

 

Votes

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.

Votes

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
Community Expert ,
Oct 11, 2019 Oct 11, 2019

Copy link to clipboard

Copied

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

 

Votes

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

Votes

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

 

Votes

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

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

Votes

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

Votes

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

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

Votes

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 Employee ,
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?

Votes

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

 

Votes

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

When using 

addTracks()

from QEDom, you might see that it inserts a videoTrack at the beginning (so there will be a new videoTrack[0] and all others are pushed above it).

 

When using 

addTracks(3)

it will prepend 3 videoTracks into the videoTracks array!

 

Now, if you set a second parameter, the desired number of videoTracks (first parameter) will be inserted after this index:

addTracks(2, 3)

inserts two videoTracks after index 3, so there will be a new empty videoTrack[4]!

 

There are even more parameters (badly explained in the object-model-viewer inside ExtendScriptToolkit -> search for QESequence, see that addTracks() accepts a bunch of number parameters...).

 

This is good if you do not want to add audioTracks "in the background" while adding a new videoTrack (which is done automatically by default):

addTracks(1, 3, 0)

will add one new videoTrack after videoTrackIndex 3, and NOT add an audioTrack!

 

(I am not sure about the fourth parameter and further ones, if you execute

addTracks(0, 0, 1, 3)

it will prepend an audioTrack to the beginning of audioTracks, no matter the fourth parameter...)

Votes

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

object-viewer-addtracks.jpg

Votes

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 Employee ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

[Fights temptation to answer questions]

QE DOM remains unsupported, and not at all recommended.

Votes

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Yes, I know 🙂


That's why I wanted people to know, because until yesterday, I thought that adding a videoTrack always adds an audioTrack.

Also, I was pretty much surprised that there are entries for QEDom in the object-model-viewer, which made me explore the addTrack() function again with a satisfying result (very nice!).

Maybe writing "badly explained" seems a little harsh, but to me it is the opposite (especially when I find a satisfying solution without dirty workaround) - because as you told so many people that QEDom is not recommended and not documented.

This does not stop us from using QEDom until it will be dropped out of availability.

We desperately need some functionality from QEDom, otherwise we could not use most of our panels.

We implement some very complex workflows which require some features from QEDom.

If QEDom was unavailable, and there wouldn't be a substitute, I would refuse to implement panels with ExtendScript (because I would have to tell my customer that some features are completely impossible - or only with really bad workarounds - e.g. adding a sequence from a preset file).

 

(off topic:)

Also, you are recommending VSCode.

I have some thoughts about VSCode:

1. it is a text-editor with plugins, which the user has to maintain

2. it is so far away from an IDE, and even more far away from a managed IDE (I use Webstorm)

3. the ExtendScript plugin in VSCode is unstable (ExtendScriptToolkit ALWAYS works - sometimes you gotta squeeze it, but it will do what I want and need)

4. when I see people working with VSCode, I have the feeling that they are slower in coding than people using an IDE (due to the concept of VSCode)

 

So, sometimes I am forced to use VSCode (if something on the MacOS is not working properly), and I only identify the problem and switch back to Windows and Webstorm to fix or change it, if that is possible.

 

I do not want to judge anyone or anything, but in my opinion, VSCode is a bad tool for coding, it does not help me at all, it blocks me from being productive (I have coded in quite some environments, including IDEs and text-editors - e.g. VI, notedpad.exe or even from the command line 😉 ).

And as we can see, after some years now, as the Toolkit is now unsupported, I still find some jewels inside of it! 🙂

 

If I see someone asking about a feature which is in QEDom, and I can help or find out, I will do that.

And I will not mind you saying again and again that this remains unsupported and disencouraged...

 

So cheers and thanks for all your answers!

Guntram

Votes

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 Employee ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

Also, you are recommending VSCode.

Definitely! 

 

I'll leave it to the philosophically-minded among us, to debate whether VSCode is really an IDE or not.  🙂

We've been using VSCode for years, with very few issues; much, much fewer than ESTK commonly displayed. Though I still miss ESTK's data browser, I do not miss having comments displayed in Comic Sans... 


Votes

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

LATEST

>> displayed in Comic Sans... 

😄 
I would prefer the Wingdings font (especially on Mac hehe)

Votes

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