Copy link to clipboard
Copied
Hello, I'm running a custom script through ExtendScript Developer Tools that creates markers to match clips/graphics on a specified track. It matches the in point and duration, and pulls the name from an element of the graphic.
//PLUS DURATION, MATCH BURN NAME:
var markers = app.project.activeSequence.markers;
var track = app.project.activeSequence.videoTracks[3];
var numClips = track.clips.numItems;
for(a=0;a<numClips;a++){
var labelName = (track.clips[a].components[3].instanceName);
var newMark = markers.createMarker(track.clips[a].start.seconds);
newMark.end = (track.clips[a].start.seconds)+(track.clips[a].duration.seconds);
newMark.name = 'LAM_119_'+labelName;
}
I then use another script I to export clips from those markers. I didn't write this second script so I don't exactly know what it's doing, but it gives me an error saying "MARKERS NOT ON WHOLE FRAMES" and "start not snapped" or "end not snapped" Once I go through and manually snap them it works fine. But that is incredibly tedious.
I've tried modifying my marker creation script to round up (see below), but I still get errors. It doesn't make sense why the markers would be placing points not on whole frames, since the edits are definitely falling on them.
// SNAP ATTEMPT
var markers = app.project.activeSequence.markers;
var track = app.project.activeSequence.videoTracks[3];
var numClips = track.clips.numItems;
for (var a = 0; a < numClips; a++) {
var labelName = track.clips[a].components[3].instanceName;
var start = track.clips[a].start.seconds;
var duration = track.clips[a].duration.seconds;
// Round start and duration to the nearest tenth
start = Math.round(start * 10) / 10; // Round start to the nearest tenth
duration = Math.round(duration * 10) / 10; // Round duration to the nearest tenth
var newMark = markers.createMarker(start);
newMark.end = start + duration;
newMark.name = 'LAM_107_' + labelName;
}
Thanks in advance!
Copy link to clipboard
Copied
>it gives me an error saying "MARKERS NOT ON WHOLE FRAMES"
Presumably, that error is coming from the other script you're using? I ask, because PPro typically doesn't ALL CAPS our error messages. 😉
Can you post all the scripts you're using (or send them to me directly)?
I imagine that's happening because you can place markers anywhere, not just at frame boundaries. It may be the case that you need to do some timecode math to determine where frame boundaries actually occur within the sequence (and framerate) in use, and place markers there.
Copy link to clipboard
Copied
It is definitely coming from the other script I'm using. I'm pasting the error-check from that script below. This script also has a function to check timebase, and uses ticks. I tried converting/rounding to ticks in my script but it still doesn't seem to work. If this is not helpful, I'll email you the full script, I was just trying to save you the digging. Thanks!
// get markers
var markers = activeSeq.markers;
if (markers) {
var numMarkers = markers.numMarkers;
if (numMarkers > 0) {
// $FRAMERATE
var sft = is23 ? 10594584000 : 8475667200;
var szp = parseInt(activeSeq.zeroPoint);
// marker info
var markerInfo = [];
var markerTicks = [];
var marker_index = 1;
var badMarkerNum = 0;
var cmDuration = 0;
var cmName = "";
var cnComm = "";
var cmStart = 0, cmEnd = 0;
var startSnap = true, endSnap = true, sFlag = "";
var snapErrors = "";
var gapErrors = "";
var nameErrors = "";
var prevEnd = undefined;
var prevName = "";
for (var current_marker = markers.getFirstMarker(); current_marker !== undefined; current_marker = markers.getNextMarker(current_marker)){
// parse start/end of markers ticks
cmStart = parseInt(current_marker.start.ticks);
cmEnd = parseInt(current_marker.end.ticks);
// get duration & name
cmDuration = cmEnd-cmStart;
cmName = current_marker.name;
cnComm = current_marker.comments;
// check if on whole frames
startSnap = (cmStart/sft) % 1 === 0;
endSnap = (cmEnd/sft) % 1 === 0;
if (!startSnap || !endSnap) {
if (!startSnap && !endSnap) {
sFlag = "start and end"
} else {
sFlag = startSnap ? "end" : "start";
}
snapErrors += "\""+(cmName==""?"Untitled":cmName)+"\": "+sFlag+" not snapped\n";
}
//check for gaps
if (prevEnd != undefined && cmDuration !== 0) {
if (prevEnd < cmStart) {
gapErrors += "Gap found between markers \""+ (prevName==""?"Untitled":prevName) + "\" and \"" + (cmName==""?"Untitled":cmName) + "\"\n";
}
}
// marker has name and duration, otherwise add to list
if (cmName !== "" && cmDuration !== 0) {
markerInfo[marker_index-1] = [cmName, current_marker.start.ticks, current_marker.end.ticks];
marker_index = marker_index + 1;
}
// add to tick list for label processing
if (cmDuration !== 0) {
markerTicks[markerTicks.length] = [cmName, parseInt(current_marker.start.ticks), parseInt(current_marker.end.ticks)];
// untitled check
if (cmName == "") {
var cmt = (szp+parseInt(current_marker.start.ticks))/254270016000; // timebase * framerate
var cm_secs = ~~cmt;
var cm_decs = cmt % 1;
var cm_mins = ~~(cm_secs/60);
var secsRem = cm_secs-(cm_mins*60);
// $FRAMERATE
var pFrame = is23 ? ~~((cm_decs*23.976)+0.5) : ~~((cm_decs*29.97)+0.5);
var cmt_ro = cm_mins+":"+secsRem+":"+pFrame;
nameErrors += "Untitled marker found @ " + cmt_ro + (cnComm !== "" ? "\n(Use 'Name', not 'Comment' field)" : "") + "\n";
}
} else {
badMarkerNum++;
}
if (cmDuration !== 0) {
prevEnd = cmEnd;
prevName = cmName;
}
}// JavaScript Document
Copy link to clipboard
Copied
var sft = is23 ? 10594584000 : 8475667200;
I'm not sure how that would ever work; full script(s), please. 🙂
Find more inspiration, events, and resources on the new Adobe Community
Explore Now