Reading, Changing, and Making Markers

As I mention in the video above, Markers Are Great!!!

What’s so great about markers is how almost every editor I have worked with seems to use them in a different way, to speed up whatever portions of their workflow they can’t stand.

Marking good clips, bad clips, good lighting, bad audio, graphics placement, SFX placement, DVD chapters, etc, the options are limitless.

And the one thing that all of the above methods have in common, is that all of them require action after the markers are placed.


So lets automate that!

First – We start with reading markers

It’s important to note, that the markers collection (which you can access via app.project.activeSequence.markers) can not be accessed like a typical collection array. We can’t just throw a [x] on the end of the collection and access the xth marker, and all of its information. We must jump through them one by one in order to do this.

Sure, this is a pain, but we can quickly store all of the information into a multi-level array using the following code, and then access this whenever we need it.

var numMarkers = app.project.activeSequence.markers.numMarkers;
var markers = app.project.activeSequence.markers;
var markAry = [];
var currentMarker;


for(a=0;a<numMarkers;a++){
var tempAry = [];
if(a==0){
currentMarker = markers.getFirstMarker();
tempAry.push(currentMarker.name);
tempAry.push(currentMarker.start.seconds);
tempAry.push(currentMarker.end.seconds);
tempAry.push(currentMarker.type);
tempAry.push(currentMarker.comments);
markAry.push(tempAry);
}
if(a>0){
currentMarker = markers.getNextMarker(currentMarker);
tempAry.push(currentMarker.name);
tempAry.push(currentMarker.start.seconds);
tempAry.push(currentMarker.end.seconds);
tempAry.push(currentMarker.type);
tempAry.push(currentMarker.comments);
markAry.push(tempAry);
}
}

Seems a bit long, but for what it does, it work great. From this point you can then access your first marker through markAry[0] and the third element of your first marker through markAry[0][2].

Second – We can change markers

This is a pretty simple idea once you grasp how to jump from one marker to the next. You can see a full example on the Adobe GitHub sample site.

So while jumping from marker to marker, your can either change the type, by using the methods:
exampleMarker.setTypeAsComment(),
exampleMarker.setTypeAsChapter(),
exampleMarker.setTypeAsSegmentation(),
or exampleMarker.setTypeAsWebLink()

or

you can change any other piece of information by targeting it directly and setting it equal to a string or number:

exampleMarker.name = "Name Goes Here",
exampleMarker.comment = "Comment Goes Here",
exampleMarker.type = "Type Goes Here",
exampleMarker.start= Start Time in Seconds Goes Here,
or exampleMarker.end= End Time in Seconds Goes Here.

Finally- We can create new markers

And this is the easiest of them all, because to create a new comment marker all you need to do is:
var newMark = markers.createMarker(x), with x being the placement time in seconds.

From here, if you’d like to change any attributes or add anything, you can simply target the newMark variable and modify the desired attributes as we did above.