Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Markers not sitting exactly on frame after Import – Frame snap script anyone?

  • Markers not sitting exactly on frame after Import – Frame snap script anyone?

    Posted by Ido Shor on February 10, 2022 at 1:07 pm

    Markers not sitting exactly on frame after Import – Frame snap script anyone?

    Hello.

    so, as the title say, after importing markers, (either by using a .csv file or EDL) from DaVinci Resolve, some of them are not sitting exactly on a frame in the AE timeline. since I use hundreds of markers its very tedious and time consuming to manual adjust each one.

    This causes issues for me while applying certain scripts which relay on the position of the markers on the timeline.

    as anyone else encounter this problem? or maybe there is a script which does a frame-snap for the markers?

    thanks!

    Ido

    👍

    Dan Ebberts replied 3 years, 4 months ago 3 Members · 3 Replies
  • 3 Replies
  • Ido Shor

    January 12, 2023 at 1:54 pm

    so… here came ChatGPT and offered this script:

    var comp = app.project.activeItem; // Get active composition

    if(comp) {

    if(comp.markerProperty.numKeys > 0) {

    var markers = comp.markerProperty; // Get markers

    var frameDuration = comp.frameDuration; // Get composition frame duration

    for (var i = 1; i <= markers.numKeys; i++) {

    var markerTime = markers.keyTime(i); // Get marker time

    var closestFrame = Math.round(markerTime / frameDuration); // Get closest frame

    markers.setCommentAtTime(markerTime, closestFrame);

    }

    } else {

    alert(“The active composition does not have any markers.”);

    }

    } else {

    alert(“No active composition.”);

    }

    after effects run in to errors there, but maybe one of you wizards can take it from there 🙂

  • Walter Soyka

    January 12, 2023 at 2:25 pm

    Can you post a sample CSV/EDL that you’re using?

  • Dan Ebberts

    January 12, 2023 at 9:31 pm

    See if this works for you:

    var comp = app.project.activeItem; // Get active composition
    if(comp) {
    if(comp.markerProperty.numKeys > 0) {
    var markers = comp.markerProperty; // Get markers
    var frameDuration = comp.frameDuration; // Get composition frame duration
    for (var i = 1; i <= markers.numKeys; i++) {
    var curMarker = markers.keyValue(i);
    var markerTime = markers.keyTime(i); // Get marker time
    var closestFrame = Math.round(markerTime / frameDuration)*frameDuration; // Get closest frame
    markers.removeKey(i);
    markers.setValueAtTime(closestFrame,curMarker);
    }
    } else {
    alert("The active composition does not have any markers.");
    }
    } else {
    alert("No active composition.");
    }


We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy