How Do I Add Markers To The Timeline Using A Script In Premiere?

In this script we will look at Markers once again. First of all, we discuss the various types of markers allowed in Premiere. Then this script will look at markers in three different ways starting by adding a comment marker to every event on the timeline. After that, we will then add regions around every event on the timeline and show how to name those regions. This is a very quick way of adding new markers and regions to the timeline and could be used to render multiple regions into multiple files.

Markers can also be placed inside clips on the timeline as well as on the timeline itself. Finally, this script will look at the markers placed inside a clip on the timeline and then will put the exact same type of marker on the timeline in the exact same location. All of the details will be copied from the clip markers and added to the timeline markers.

Join us as we learn how to access all of the various details of each marker and add markers of all types to the timeline.

Add a Marker to every clip on the timeline:

var mySequence = app.project.activeSequence;
var trackTypeList = mySequence.videoTracks;
var thisTrack = trackTypeList[0];
for (var i = 0; i < thisTrack.clips.numItems; i++)
{
     var tclip = thisTrack.clips[i];
     mySequence.markers.createMarker(tclip.start.seconds);
}

Add a Region to every clip on the timeline and name the region with the name of the clip.

 var mySequence = app.project.activeSequence;
 var trackTypeList = mySequence.videoTracks;
 var thisTrack = trackTypeList[0];
 for (var i = 0; i < thisTrack.clips.numItems; i++)
 {
     var tclip = thisTrack.clips[i];
     var myMarker = mySequence.markers.createMarker(tclip.start.seconds);
     myMarker.end = tclip.end.seconds;
     myMarker.name = tclip.name;
 }

Promote all markers of all types from a clip to the main timeline.

var mySequence = app.project.activeSequence;
var trackTypeList = mySequence.videoTracks;
var thisTrack = trackTypeList[0];

for (var i = 0; i < thisTrack.clips.numItems; i++)
{
     var tclip = thisTrack.clips[i];
     var binClip = tclip.projectItem;
     var markerCount = binClip.getMarkers().numMarkers;
     var currentMarker = null;
     var PreviousMarker = null;

     for (j = 0; j < markerCount; j++)
     {
         if (j == 0)
         {
             currentMarker = binClip.getMarkers().getFirstMarker();
         }
         else
         {
             previousMarker = currentMarker;
             currentMarker = binClip.getMarkers().getNextMarker(previousMarker);
         }

         myMarker = mySequence.markers.createMarker(tclip.start.seconds + currentMarker.start.seconds - 3600);
         myMarker.name = currentMarker.name;
         myMarker.setColorByIndex(currentMarker.getColorByIndex());
         myMarker.comments = currentMarker.comments;

         switch (currentMarker.type.toString())
         {
             case "Comment":
                 myMarker.setTypeAsComment();
                 break;
             case "Chapter":
                 myMarker.setTypeAsChapter();
                 break;
             case "Segmentation":
                 myMarker.setTypeAsSegmentation();
                 break;
             case "WebLink":
                 myMarker.setTypeAsWebLink(currentMarker.getWebLinkURL(), currentMarker.getWebLinkFrameTarget());
                 break;
             default:
                 break;
         }
     }
}

Please sign up here and leave comments with suggestions of tasks you would like to see automated. You can help guide the direction of these videos. Also, please subscribe to my YouTube channel.

Leave a Reply