Markers at Intervals, But Only at Event Start

johnmeyer wrote on 2/1/2007, 9:31 PM
Adding markers at regular intervals always seemed dumb. Who wants a chapter stop in the middle of a scene? So, I modified an existing script by Ed so that you get markers at more-or-less regular intervals, but only at the beginning of events on the selected track. Probably useful to about two people in the universe, but it was easy to do.

[Edited to improve consistency of where markers get placed. -Feb 3, 2007]

/**
* This script will add markers at regular intervals,
* but only at events on the selected track, and only at
* event boundaries.
*
* Based on a script by: Edward Troxel
* Written by John Meyer February 1, 2007
**/

import System;
import System.IO;
import System.Windows.Forms;
import Sony.Vegas;

//Change this value to be the desired interval
//Format: hh:mm:ss:ff (hours:minutes:seconds:frames)
var Interval = "00:00:55:00";

try {
var myMarker : Marker;
var IncTime : Timecode = new Timecode(Interval);
var CurrTime : Timecode = IncTime;

//Find the selected event
var track = FindSelectedTrack();
if (null == track)
throw "no selected track";

for (var evnt in track.Events) {
if ( CurrTime <= evnt.Start ){
//Put a marker at the start point
if ( !MarkerExist(evnt.Start.ToMilliseconds()) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
}
CurrTime = evnt.Start + IncTime;
} // End if CurrTime
} // End for var evnt



} catch (e) {
MessageBox.Show(e);
}


function FindSelectedTrack() : Track {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
if (track.Selected) {
return track;
}
trackEnum.moveNext();
}
return null;
}



// Function to check if there is a marker at timecode passed to this function
// Timecode (dStart) must be in milliseconds
function MarkerExist (dStart) : boolean {

var fmarkerEnum = new Enumerator(Vegas.Project.Markers);

while (!fmarkerEnum.atEnd()) {
var fMyMarker = fmarkerEnum.item();
var fMarkerStart = fMyMarker.Position.ToMilliseconds();
if ( dStart == fMarkerStart ) {
return 1;
}

fmarkerEnum.moveNext();

} // End while fmarkerEnum

return 0;
}


Comments

Grazie wrote on 2/2/2007, 9:51 AM


John, your efforts are appluaded by this "Edit-Grunt"!

Where & When & If I use it, I will think of you 2 guys.

THANK YOU!!!


johnmeyer wrote on 2/2/2007, 10:52 AM
Yeah, this one might actually be useful. Simply placing markers at exact, regular intervals never seemed to make any sense to me.
Grazie wrote on 2/3/2007, 12:39 AM
"so that you get markers at more-or-less regular intervals, but only at the beginning of events on the selected track. "

But I get this with Excalibur? What is it that is different here? I HAVE to be doing, understanding something differently? - Sorry John, confused of London here . ..
JohnnyRoy wrote on 2/3/2007, 7:29 AM
> Simply placing markers at exact, regular intervals never seemed to make any sense to me.

If you are transferring VHS tapes to DVD there are no breaks in the scenes to go by. It's just one long capture. In this case, placing a marker at 10 minute intervals throughout an hour or two hour tape is better than nothing. I wish DVD Architect had this feature because I capture my tapes directly to MPEG2 so I can just burn the DVD and be done with it.

~jr
johnmeyer wrote on 2/3/2007, 9:08 AM
The original free (and still available) Scenalyzer has optical scene detection which can be applied after the fact. It can also be done with an AVISynth script. I've actually toyed with the idea of writing a small script that would output the scene markers to a text file that could then simply be pasted into the Edit Details dialog. That would avoid having to actually copy the huge AVI files. The scene detection you can do with AVISynth can actually be pretty good (there is some motion estimation software that has to do scene detection to avoid tracking objects across scene changes, and it outputs a flag whenever it detects a new scene).
johnmeyer wrote on 2/3/2007, 9:34 AM
But I get this with Excalibur? What is it that is different here?

No you don't. Excalibur has a "Marker Interval" that you can set. It has a "Place Marker At Each Event" checkbox. But the two don't interact. The Place Marker At Each Event gives you a marker at each and every event. That is probably a LOT more markers than you want. The "Marker Interval" gives you markers in the middle of an event. Who wants to have a chapter stop in the middle of a golf swing? You want to start at the beginning of a scene. So, the obvious thing is to have a script that puts down a marker, moves ahead by the specified interval, and then looks around and says, "Is there the beginning of an event nearby?" It goes to the nearest event start (actually in this ultra-dumb version it always moves ahead to look for the next event start), and puts a marker there.

Ed, if you like this idea, please feel free to steal it and put it in Excalibur. For those that don't have Excalibur or Ultimate S, you should definitely look at them. I have looked at both of them and happen to own Excalibur. Amazing productivity gains and wonderful piece of work, both of them.

John