Audit to find events with duplicate fX

johnmeyer wrote on 8/29/2006, 6:17 PM
Vegas has a great feature, namely the ability to "paste event attributes." You can use this to quickly take all fX on one event and apply them to another event.

Unfortunately, when you paste, Vegas adds these fX to any that are already in existence for that event. This is usually what you want EXCEPT when you have already applied another instance of the same fX. In this case, you end up with a double-whammy, with the same fX acting twice on the same event. Perhaps this is what some people wanted, but it sure isn't what I want. In my workflow, I often end up with two Color Corrector, or multiple copies of the Levels fX, and then wonder why the video looks so odd. What's really bad is that sometimes my color corrections are subtle, and I don't notice the problem right away.

Sooo ...

I wrote another "auditing" script, which if it "sells" as fast as my last one, will be used by at least five people by the end of the century. However, if it helps even one poor soul, perhaps it was worth the time to post it. Since the last few scripts didn't generate any interest, I'm not going to bother to upload it anywhere.

/**
* This script will find and highlight all video events
* that contain more than one instance of the same fX.
* It also puts a marker at the start of each such event.
* You can then remove the duplicate fX if you did not intend
* to apply the same fX to the same event more than once.
*
* This only works on video tracks. You must select a track
* before running the script.
*
* If a marker already exists at the beginning of an event, no
* marker will be added. However, the event will be selected, so
* you will still be able to see which events need to be fixed.
*
* Written By: John Meyer
* 8-29-2006
**/

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

var myMarker : Marker;

try {
var track = FindSelectedTrack(); //Use this function to find the first selected track.

//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if ( evnt.IsVideo() ) { // Only operate on video events
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event
var videoEvent = VideoEvent(evnt);
var stopit = 0;
if (videoEvent.Effects.Count>1) {
for (var i=videoEvent.Effects.Count -1; i >= 0; i--) {
var effect = videoEvent.Effects[i];
for (var j=i-1; j >= 0; j--) {
var duptest = videoEvent.Effects[j];
if (effect.PlugIn.Name==duptest.PlugIn.Name) {
evnt.Selected = true; // Select the event
if (!MarkerExist(evnt.Start.ToMilliseconds()) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
myMarker.Label = "*** "+effect.PlugIn.Name;
}
stopit = 1;
break;
} // End if (effect == duptest)
} // End for j
if (stopit == 1) {
break;
}
} // End for i
} // End if (i>1)
eventEnum.moveNext();
} // End while (!eventEnum.atEnd())
} // End if ( evnt.IsVideo() )
Vegas.UpdateUI();

} 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 MarkerExist (dStart) : boolean {

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

while (!markerEnum.atEnd()) {
myMarker = markerEnum.item(); // myMarker is a global function in this project
var MarkerStart = myMarker.Position.ToMilliseconds();

if ( dStart == MarkerStart ) {
return 1;
}

markerEnum.moveNext();

} // End while markerEnum

return 0;
}


Comments

rmack350 wrote on 8/29/2006, 9:28 PM
Thanks John,

I added it to my scripts and it works. Drops markers and labels them with the name of one of the offending FX.

Rob Mack
Grazie wrote on 8/29/2006, 11:29 PM
John, this sounds perfect for this headbanging messy editor. However, I must have done something wrong to get this error - running V6:


@@@@@@@@@@@@@@@@@@@@@@@@

Compilation error on line 2:

Expecting more source characters


System.ApplicationException: Failed to compile script: 'C:\Documents and Settings\Main User\Desktop\FindFx.js'
at Sony.Vegas.VSAManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)

@@@@@@@@@@@@@@@@@@@@@@@@




. .this is a "copy" of the innards:


@@@@@@@@@@@@@@@@@@@@@@@@
/** * This script will find and highlight all video events * that contain more than one instance of the same fX. * It also puts a marker at the start of each such event. * You can then remove the duplicate fX if you did not intend * to apply the same fX to the same event more than once. * * This only works on video tracks. You must select a track * before running the script. * * If a marker already exists at the beginning of an event, no * marker will be added. However, the event will be selected, so * you will still be able to see which events need to be fixed. * * Written By: John Meyer * 8-29-2006 **/import System;import System.Text;import System.IO;import System.Windows.Forms;import Sony.Vegas;var myMarker : Marker;try { var track = FindSelectedTrack(); //Use this function to find the first selected track. //Go through the list of Events var eventEnum = new Enumerator(track.Events); var evnt : TrackEvent = TrackEvent(eventEnum.item()); if ( evnt.IsVideo() ) { // Only operate on video events while (!eventEnum.atEnd()) { evnt = TrackEvent(eventEnum.item()); evnt.Selected = false; // De-select the event var videoEvent = VideoEvent(evnt); var stopit = 0; if (videoEvent.Effects.Count>1) { for (var i=videoEvent.Effects.Count -1; i >= 0; i--) { var effect = videoEvent.Effects[i]; for (var j=i-1; j >= 0; j--) { var duptest = videoEvent.Effects[j]; if (effect.PlugIn.Name==duptest.PlugIn.Name) { evnt.Selected = true; // Select the event if (!MarkerExist(evnt.Start.ToMilliseconds()) ) { myMarker = new Marker(evnt.Start); Vegas.Project.Markers.Add(myMarker); myMarker.Label = "*** "+effect.PlugIn.Name; } stopit = 1; break; } // End if (effect == duptest) } // End for j if (stopit == 1) { break; } } // End for i } // End if (i>1) eventEnum.moveNext(); } // End while (!eventEnum.atEnd()) } // End if ( evnt.IsVideo() ) Vegas.UpdateUI(); } 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 MarkerExist (dStart) : boolean { var markerEnum = new Enumerator(Vegas.Project.Markers); while (!markerEnum.atEnd()) { myMarker = markerEnum.item(); // myMarker is a global function in this project var MarkerStart = myMarker.Position.ToMilliseconds(); if ( dStart == MarkerStart ) { return 1; } markerEnum.moveNext(); } // End while markerEnum return 0;}



@@@@@@@@@@@@@@@@@@@@@@@@







Grazie wrote on 8/29/2006, 11:37 PM
John, I've just repeated the same through Word Pad instead of Notepad.

This is a copy back to here. What am I doing wrong? I'm now getting a "Compilation Error on line1"?


@@@@@@@@@@@@@@@@@@@@@@@@@


/**
* This script will find and highlight all video events
* that contain more than one instance of the same fX.
* It also puts a marker at the start of each such event.
* You can then remove the duplicate fX if you did not intend
* to apply the same fX to the same event more than once.
*
* This only works on video tracks. You must select a track
* before running the script.
*
* If a marker already exists at the beginning of an event, no
* marker will be added. However, the event will be selected, so
* you will still be able to see which events need to be fixed.
*
* Written By: John Meyer
* 8-29-2006
**/

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

var myMarker : Marker;

try {
var track = FindSelectedTrack(); //Use this function to find the first selected track.

//Go through the list of Events
var eventEnum = new Enumerator(track.Events);
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if ( evnt.IsVideo() ) { // Only operate on video events
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event
var videoEvent = VideoEvent(evnt);
var stopit = 0;
if (videoEvent.Effects.Count>1) {
for (var i=videoEvent.Effects.Count -1; i >= 0; i--) {
var effect = videoEvent.Effects[i];
for (var j=i-1; j >= 0; j--) {
var duptest = videoEvent.Effects[j];
if (effect.PlugIn.Name==duptest.PlugIn.Name) {
evnt.Selected = true; // Select the event
if (!MarkerExist(evnt.Start.ToMilliseconds()) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
myMarker.Label = "*** "+effect.PlugIn.Name;
}
stopit = 1;
break;
} // End if (effect == duptest)
} // End for j
if (stopit == 1) {
break;
}
} // End for i
} // End if (i>1)
eventEnum.moveNext();
} // End while (!eventEnum.atEnd())
} // End if ( evnt.IsVideo() )
Vegas.UpdateUI();

} 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 MarkerExist (dStart) : boolean {

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

while (!markerEnum.atEnd()) {
myMarker = markerEnum.item(); // myMarker is a global function in this project
var MarkerStart = myMarker.Position.ToMilliseconds();

if ( dStart == MarkerStart ) {
return 1;
}

markerEnum.moveNext();

} // End while markerEnum

return 0;
}


@@@@@@@@@@@@@@@@@@@@@@@@@


Hope you can help?
jetdv wrote on 8/30/2006, 6:58 AM
Do you really have the @@@@@@@@@ in there????


Or is line 1: /**

johnmeyer wrote on 8/30/2006, 9:21 AM
I have no idea what you did, but here's a temporary link to the script file:

Highlight events that contain duplicate fx.js
MarkWWW wrote on 8/30/2006, 11:26 AM
Thanks again John - another potentially useful script.

If I might make a suggestion: It would be nice if, as well as highlighting the events in question and adding the markers, it popped up a MsgBox saying "No events with duplicate FXs found" or "4 events with duplicate Fxs found" or whatever was appropriate, as a summary of what, if anything, it had found on that occasion.

Thanks again.

Mark
Grazie wrote on 8/30/2006, 1:41 PM
No, it is not in the script.
Grazie wrote on 8/30/2006, 1:56 PM
Thank you John!

Works a treat!!
johnmeyer wrote on 9/1/2006, 7:59 AM
Good idea about the message box alerts. Here's a version with that enhancement:
/**
* This script will find and highlight all video events
* that contain more than one instance of the same fX.
* It also puts a marker at the start of each such event.
* You can then remove the duplicate fX if you did not intend
* to apply the same fX to the same event more than once.
*
* This only works on video tracks. You must select a track
* before running the script.
*
* If a marker already exists at the beginning of an event, no
* marker will be added. However, the event will be selected, so
* you will still be able to see which events need to be fixed.
*
* Written By: John Meyer
* 8-29-2006
* Revised 9-1-2006 to add MessageBox alerts.
**/

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

var myMarker : Marker;

try {
var track = FindSelectedTrack(); //Use this function to find the first selected track.

//Go through the list of Events
var count=0;
var eventEnum = new Enumerator(track.Events);
var evnt : TrackEvent = TrackEvent(eventEnum.item());
if ( evnt.IsVideo() ) { // Only operate on video events
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
evnt.Selected = false; // De-select the event
var videoEvent = VideoEvent(evnt);
var stopit = 0;
if (videoEvent.Effects.Count>1) {
for (var i=videoEvent.Effects.Count -1; i >= 0; i--) {
var effect = videoEvent.Effects[i];
for (var j=i-1; j >= 0; j--) {
var duptest = videoEvent.Effects[j];
if (effect.PlugIn.Name==duptest.PlugIn.Name) {
evnt.Selected = true; // Select the event
count = count + 1;
if (!MarkerExist(evnt.Start.ToMilliseconds()) ) {
myMarker = new Marker(evnt.Start);
Vegas.Project.Markers.Add(myMarker);
myMarker.Label = "*** "+effect.PlugIn.Name;
}
stopit = 1;
break;
} // End if (effect == duptest)
} // End for j
if (stopit == 1) {
break;
}
} // End for i
} // End if (i>1)
eventEnum.moveNext();
} // End while (!eventEnum.atEnd())
} // End if ( evnt.IsVideo() )
if (count == 0) {
MessageBox.Show("No duplicate effects were found.")
} else {
if (count == 1) {
MessageBox.Show("This track contains one event with duplicate effects.")
} else {
MessageBox.Show("This track contains " + count + " events with duplicate effects.")
}
}
Vegas.UpdateUI();

} 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 MarkerExist (dStart) : boolean {

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

while (!markerEnum.atEnd()) {
myMarker = markerEnum.item(); // myMarker is a global function in this project
var MarkerStart = myMarker.Position.ToMilliseconds();

if ( dStart == MarkerStart ) {
return 1;
}

markerEnum.moveNext();

} // End while markerEnum

return 0;
}
MarkWWW wrote on 9/1/2006, 12:12 PM
Perfect - thanks again.

Mark
Grazie wrote on 9/5/2006, 1:43 AM
Well, John, that is excellent!

I appear not to be able to use NOTEPAD - which I have done before, hey PCs huh?

I've just run the latest and I get a neat message box telling me I have so many duped FXs, great!

The markers inform me WHAT duplicated FXs there are - great!

Tell me, is there any way I can show if I have MORE than one type duplicated?

I've also noticed that it doesn't appear to matter which dupes appear on the "chain" first, for them to be "shown" within the Marker? Is this correct?