Skip to main content
SimonBjörk
Known Participant
Mar 22, 2016 2:25 PM UTC
Answered

Selected clip in timeline?

Is there anyway to get the selected clip in a timeline using ExtendScript? And also get that clips in/out point (and other metadata).

If not, any plans to implement it? I'm currently looking to do a "Publish" tool in Premiere for a vfx pipeline and I need to be able to "do stuff" on the selected clip.

/Simon

phlexib
phlexibCorrect answer
Inspiring
Aug 26, 2016 3:44 PM UTC

hi,

I know it's a old question, but yes you can do that.

you can loop through a trackItemCollection , and check for the isSelected() property. It returns a boolean, if true, you can get still from the trackItem, both inPoint and outPoint.

var seq = app.project.activeSequence;

var tracks = seq.videoTracks;

// check only for the first track

var firstTrackItems = tracks[0].clips;

for ( var i=0 ; i< firstTrackItems.numItems ; i++){

        var currentClip = firstTrackItems;

        if( firstTrackItems.isSelected()){

            // do whatever you want with the clip

            alert( firstTrackItems.start.seconds);

            }

    }

Ben

19 replies

SWAX
Inspiring
Nov 4, 2017 2:31 PM UTC

Bruce Bullis​ -- has this been updated in recent API updates? The possibility to get the selected clip(s) ranges (inpoint/outpoint)?

Translate
Aecorn
Inspiring
Feb 5, 2018 5:26 PM UTC

You can get the inpoint of a trackitem I think.

var clipIn = foundVideo.inPoint.ticks;

Currently struggeling to modify what Bruce Bullis​ called "master clips" in another thread. The link he posted is dead.

Im wanting to place a projectItem into the selected track at the selected time (code is doing this already), what Im looking for is setting the "clip in" time and "clip out" time equal to a trackItem already in the active sequence.

  var clipIn = foundVideo.inPoint.ticks;

  var editIn = foundVideo.start.ticks;

        

  projectItem.InPoint.ticks = clipIn;

//or

projectItem.setInPoint(clipIn).ticks;

//does not work, what should I look for? Is manipulating projectItems the wrong way around this?

var clipIn = foundVideo.inPoint.seconds;

projectItem.setStartTime(clipIn) ;

//only works on subclips?

        

activeSequence.videoTracks[1].insertClip(projectItem, editIn);

Translate
Bruce Bullis
Legend
Feb 5, 2018 5:29 PM UTC
phlexib
phlexibCorrect answer
Inspiring
Aug 26, 2016 3:44 PM UTC

hi,

I know it's a old question, but yes you can do that.

you can loop through a trackItemCollection , and check for the isSelected() property. It returns a boolean, if true, you can get still from the trackItem, both inPoint and outPoint.

var seq = app.project.activeSequence;

var tracks = seq.videoTracks;

// check only for the first track

var firstTrackItems = tracks[0].clips;

for ( var i=0 ; i< firstTrackItems.numItems ; i++){

        var currentClip = firstTrackItems;

        if( firstTrackItems.isSelected()){

            // do whatever you want with the clip

            alert( firstTrackItems.start.seconds);

            }

    }

Ben

Translate
Bruce Bullis
Legend
Aug 29, 2016 1:41 PM UTC

Nicely done, Ben—though I wasn't kidding, we are working on better timeline selection handling, through the API.

Translate
phlexib
Inspiring
Aug 29, 2016 11:53 PM UTC

I just started trying to figure out script in Premiere, and coming from After Effect, I cried and pull my hair a few times already.

Especially because I do feel that there's actually a lot more tasks to automate in an Editing software.

So thank you, for helping the community, and good luck with the API.

Translate
Bruce Bullis
Legend
Mar 22, 2016 5:13 PM UTC

There's no way to do that...today.

Yes, we have plans.

Translate
Participant
Aug 25, 2024 11:06 AM UTC

Sooo, did you manage to follow through with those plans in these 8 years of time?

Translate