SlideShowToMarkers Error? at DVinfo.net
DV Info Net

Go Back   DV Info Net > Windows / PC Post Production Solutions > What Happens in Vegas...
Register FAQ Today's Posts Buyer's Guides

What Happens in Vegas...
...stays in Vegas! This PC-based editing app is a safe bet with these tips.

Reply
 
Thread Tools Search this Thread
Old August 19th, 2004, 06:37 AM   #1
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
SlideShowToMarkers Error?

OK, I'll try here as well .. . .

Having updated to V5b I'm now getting this. I've activated it from my Desktop. I get the same from running from the Script Menu too. I know that wouldn't make a difference. OK, this is what I'm getting:-

_______________________________________________


Error 0x80131600 (message missing)

Compilation error on line 24:

Variable 'Timecode' has not declared


System.ApplicationException: Failed to compile script: 'C:\Documnets and Settings\Main User\Desktop\slideshowToMarkers.js'
at Sony.Vegas.ScriptHost.RunScript()

_______________________________________________


HELP!

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 06:47 AM   #2
RED Code Chef
 
Join Date: Oct 2001
Location: Holland
Posts: 12,514
Sounds like that script is just not correct. The script you are trying
to access is looking for a variable that is not declared (ie, it is not
there). If you e-mail me the script I can take a look at it for you
if you want.

Otherwise your installation of .NET runtime might be corrupt.
__________________

Rob Lohman, visuar@iname.com
DV Info Wrangler & RED Code Chef

Join the DV Challenge | Lady X

Search DVinfo.net for quick answers | Buy from the best: DVinfo.net sponsors
Rob Lohman is offline   Reply With Quote
Old August 19th, 2004, 06:52 AM   #3
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
Thanks Rob . .

1 - I can run other scripts within V5b .. including all versions XCAL, Neon and Tsunami. I understand they need .NET 1.1? So I would ahve thought that as I can run these other scripts then .NET isn't corrupt?

2 - Do you want me to copy the script into this post or email you?

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 06:53 AM   #4
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
Rob - Sent email .. .

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 06:58 AM   #5
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
Rob, email being "bumped" back ..

so here yah go ..

Script Starts Here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


// Assuming there is an audio track with appropriate number of numbered and
// unnumbered markers, and a bin in Media Pool with images, automate image
// sequence to timeline at markers. Apply default transition/dissolve in the
// process.
// Currently script accept both images and video clips (only video part is
// used) as slides.
// User can choose bin (by name), amount of overlap, affected region (see in
// the script code), and whether to create a new track for the batch (otherwise
// currently selected track is used if it has type Video).
// All setting are stored in Windows Registry between subsequent runs and
// sessions.
// Preliminary sortingof media by path/name is implemented but turned off.
// So media is picked in the order it is stored in the bin.
// Every run media is picked from the bin starting with the very first item.
// Maybe pick images from directory in future versions.
//

import System.Windows.Forms;
import System.Collections;
import Sony.Vegas;
import Microsoft.Win32;

// This is for convenience in comparison and assignment.
var zeroMark = new Timecode(0);
// These are default values for parameters in a dialog.
// Half-time of dissolve. Half because we add it to both dissolving clips.
var overlap: Timecode;
// Region that is subject to script. By default it is entire project.
var begin: Timecode, end: Timecode;
// Default name for bin holding our slides.
var binName;
// 0 - entire project, 1 - from cursor to the end of project, 2 - loop region.
var regionType;
// 0 - add images to current track, else create a new track
var newTrack;

try {
// Last snapshot file name is stored in Windows registry.
var regKey = Registry.CurrentUser.CreateSubKey("Software\\Sonic Foundry\\Scripts\\SlideshowToMarkers");
binName = regKey.GetValue("Bin name", "Slides");
overlap = new Timecode(regKey.GetValue("Overlap", "00:00:01:29")); // Approximately 2 seconds.
regionType = regKey.GetValue("Region", 1);
newTrack = regKey.GetValue("New track", 1);

var dialog = new SlideshowDialog(binName, overlap, regionType, newTrack);
var dialogResult = dialog.ShowDialog();

// if the OK button was pressed...
if (System.Windows.Forms.DialogResult.OK == dialogResult) {
binName = dialog.binNameBox.Text;
overlap = new Timecode(dialog.overlapBox.Text);
regionType = dialog.regionBox.SelectedIndex;
newTrack = dialog.trackBox.Checked ? 1 : 0;
switch (regionType) {
case 0: begin = zeroMark; end = Vegas.Project.Length; break;
// If there's no selection then SelectionLength is 0 (zero).
case 2: begin = Vegas.SelectionStart; end = begin + Vegas.SelectionLength; break;
default: begin = Vegas.Cursor; end = Vegas.Project.Length;
}
// Write settings back to Registry.
regKey.SetValue("Bin name", binName);
regKey.SetValue("Overlap", overlap.ToString());
regKey.SetValue("Region", regionType);
regKey.SetValue("New track", newTrack);

// If event is shorter than this then its all just transition.
// That will look bad aestethically.
var threshold = overlap + overlap;

var videoTrack = FindSelectedTrack();
if ((newTrack != 0) || !videoTrack.IsVideo()) {
videoTrack = new VideoTrack(videoTrack.DisplayIndex, null);
Vegas.Project.Tracks.Add(videoTrack);
}

var mrkEnum = new Enumerator(Vegas.Project.Markers);
// Two variables to identify start and end of created event.
var prevMark: Timecode = begin, currMark: Timecode = begin;

// Find the bin containing slides.
var bin = FindMediaBin(Vegas.Project.MediaPool.RootMediaBin, binName);
if (bin == null) {
MessageBox.Show("Could not find '" + binName + "' bin in Media Pool.");
} else {
var imgEnum: Enumerator;
// Build a list of available media, sort it, and then iterate it instead
// of working directly with bin/media pool.
if (false) {
var mediaList: System.Array = System.Array.CreateInstance(System.Object, bin.Count);
bin.CopyTo(mediaList, 0);
var myComparer: IComparer = new CompareMedia();
System.Array.Sort(mediaList, myComparer);
imgEnum = new Enumerator(mediaList);
} else {
// For now, position on first image in the bin.
imgEnum = new Enumerator(bin);
}
// Code below is to advance currMark until the length of event will be
// greater than threshold. Then subsequent slide is put on the timeline
// thus creating an event.
while (!mrkEnum.atEnd()) {
currMark = Marker(mrkEnum.item()).Position;
if ((currMark > begin) && ((currMark - prevMark) > threshold)) {
PlaceImageOnTimeline(imgEnum, prevMark, currMark);
prevMark = currMark;
}
if (currMark >= end) break; // To avoid extra looping after we reach end of processing region.
mrkEnum.moveNext();
}
// The last marker may not mark the end of processing region.
// This special case is handled by code below. Notice that we compare to
// overlap here because for the last event dissolve is applied on one side
// only. Would be good to handle the first event in similar way ..
currMark = end;
if ((currMark - prevMark) > overlap) {
PlaceImageOnTimeline(imgEnum, prevMark, currMark);
}
}
}
} catch (e) {
MessageBox.Show(e);
}

// Retrieve the next available image and create event on timeline.
function PlaceImageOnTimeline(images: Enumerator, from: Timecode, to: Timecode): void {
// Advance to next image.
var imgStream: MediaStream = FindNextImage(images);
if (imgStream == null)
return;
// Add handles for dissolve. Transition is centered on marker.
// Keep timecodes withing the range of audio track.
from -= overlap;
if (from < begin) from = begin;
to += overlap;
if (to > end) to = end;
// Create the new video event and add it to the track.
var evnt = new VideoEvent(from, to - from);
videoTrack.Events.Add(evnt);
// Create a new take using the video stream.
var takeName = null;
evnt.Takes.Add(new Take(imgStream, true, takeName));
}

// Walk the bin tree recursively until the 'name' is found.
// If several bins on different levels have the same name, first one will be
// returned.
function FindMediaBin(parent: MediaBin, name: String): MediaBin {
if (String.Compare(parent.Name, name) == 0) {
return parent;
}
var binEnum = new Enumerator(parent);
while (!binEnum.atEnd()) {
var abin = binEnum.item();
if ((abin instanceof MediaBin) && (abin.Name != parent.Name)) {
// Recurse here.
abin = FindMediaBin(abin, name);
if (abin != null)
return abin;
}
binEnum.moveNext();
}
return null;
}

// Get next available media as video stream. There is no check if this is
// slide/image. Any media containing video is acceptable.
function FindNextImage(mediaEnum: Enumerator): MediaStream {
while (!mediaEnum.atEnd()) {
var img = mediaEnum.item();
mediaEnum.moveNext();
if ((img instanceof Media) && Media(img).HasVideo()) {
return img.Streams.GetItemByMediaType(MediaType.Video, 0);
}
}
return null;
}

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;
}

end first part ~~~~~~~~~~~~~~~~~~~~~~~~
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 07:02 AM   #6
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
. . .second half of script . . .

SECOND PART STARTS HERE ~~~~~~~~~~~~~~~~~~~~~~~~~~


// Form subclass that is the dialog box for this script
class SlideshowDialog extends Form {
var binNameBox;
var overlapBox;
var regionBox;
var trackBox;

function SlideshowDialog(binName, overlap, region, newtrack) {

this.Text = "Create Slideshow";
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
this.Width = 300;

var buttonWidth = 80;

binNameBox = addTextControl("Bin Name", 10, 200, 10, binName);
overlapBox = addTextControl("Overlap Time", 10, 140, binNameBox.Bottom + 16, overlap.ToString());

var label = new Label();
label.AutoSize = true;
label.Text = "Region:";
label.Left = 10;
label.Top = overlapBox.Bottom + 20;
Controls.Add(label);
regionBox = new ComboBox();
regionBox.DropDownWidth = 100;
regionBox.Left = label.Right;
regionBox.Top = overlapBox.Bottom + 16;
regionBox.Items.Add("Entire Timeline");
regionBox.Items.Add("From Cursor");
regionBox.Items.Add("Loop Region");
regionBox.SelectedIndex = region;
Controls.Add(regionBox);

trackBox = new CheckBox();
trackBox.Left = 10;
trackBox.Width = 160;
trackBox.Top = regionBox.Bottom + 16;
trackBox.Text = "Create new track";
trackBox.Checked = newtrack != 0;
Controls.Add(trackBox);

var buttonTop = trackBox.Bottom + 16;

var okButton = new Button();
okButton.Text = "OK";
okButton.Left = this.Width - (2*(buttonWidth+10));
okButton.Top = buttonTop;
okButton.Width = buttonWidth;
okButton.Height = okButton.Font.Height + 12;
okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
AcceptButton = okButton;
Controls.Add(okButton);

var cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Left = this.Width - (1*(buttonWidth+10));
cancelButton.Top = buttonTop;
cancelButton.Height = cancelButton.Font.Height + 12;
cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
CancelButton = cancelButton;
Controls.Add(cancelButton);

var titleHeight = this.Height - this.ClientSize.Height;
this.Height = titleHeight + okButton.Bottom + 8;
}

function addTextControl(labelName, left, width, top, defaultValue) {
var label = new Label();
label.AutoSize = true;
label.Text = labelName + ":";
label.Left = left;
label.Top = top + 4;
Controls.Add(label);

var textbox = new TextBox();
textbox.Multiline = false;
textbox.Left = label.Right;
textbox.Top = top;
textbox.Width = width - (label.Width);
textbox.Text = defaultValue;
Controls.Add(textbox);

return textbox;
}

}

class CompareMedia implements IComparer {
function Compare(x: Object, y: Object): int {
if (!(x instanceof Media)) {
if (y instanceof Media) {
return 1;
} else {
return 0;
}
} else if (!(y instanceof Media)) {
return -1;
}
return String.Compare(Media(x).FilePath, Media(y).FilePath);
}
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Script Ends Here


TIA

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 07:17 AM   #7
Sponsor: JET DV
 
Join Date: Dec 2001
Location: Southern Illinois
Posts: 7,953
The key to this error is to look at the "import" line for Vegas.

For Vegas 4, the import line MUST read:
import SonicFoundry.Vegas;

For Vegas 5, the import line MUST read:
import Sony.Vegas;
Edward Troxel is offline   Reply With Quote
Old August 19th, 2004, 07:23 AM   #8
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
But it is there. It says

import Sony.Vegas;

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 09:04 AM   #9
Sponsor: JET DV
 
Join Date: Dec 2001
Location: Southern Illinois
Posts: 7,953
Just tested the version you sent me directly. It runs fine in Vegas 5.0b. Just make doubly sure you are picking the proper script from within Vegas.
Edward Troxel is offline   Reply With Quote
Old August 19th, 2004, 09:12 AM   #10
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
Edward, thank you. I started from "fresh" with the script that worked within V4 . . did the conversion to V5b and . . NOW it works ! ! . . Thanks Guys for your feedback . . .

. . time to lie down I think .. . arrrggghh ..

Grazie
Graham Bernard is offline   Reply With Quote
Old August 19th, 2004, 12:14 PM   #11
RED Code Chef
 
Join Date: Oct 2001
Location: Holland
Posts: 12,514
Grazie: hmmm, weird it bumped back. Can you tell me what the
error message said? Oh well, glad you got your problem solved!
__________________

Rob Lohman, visuar@iname.com
DV Info Wrangler & RED Code Chef

Join the DV Challenge | Lady X

Search DVinfo.net for quick answers | Buy from the best: DVinfo.net sponsors
Rob Lohman is offline   Reply With Quote
Old August 20th, 2004, 12:34 AM   #12
Old Boot
 
Join Date: Aug 2002
Location: London UK
Posts: 3,633
Thanks Rob! Yeah so was I. I re-downloaded the script from the NEW VASST site, did the adjustments, re-loaded into the script menu and fired iot up .. it worked . . I was under p[ressure to get it working as I was doing a demo last night, and I wanted to disply the scripting value of Vegas at the event. .. . phew!

oh . .. the error mnessgae was a "Spraynet" error message? I'll retest now to see . . yeah? If I get the error how can I email it to you? . . .

Grazie
Graham Bernard is offline   Reply
Reply

DV Info Net refers all where-to-buy and where-to-rent questions exclusively to these trusted full line dealers and rental houses...

B&H Photo Video
(866) 521-7381
New York, NY USA

Scan Computers Int. Ltd.
+44 0871-472-4747
Bolton, Lancashire UK


DV Info Net also encourages you to support local businesses and buy from an authorized dealer in your neighborhood.
  You are here: DV Info Net > Windows / PC Post Production Solutions > What Happens in Vegas...


 



All times are GMT -6. The time now is 05:18 AM.


DV Info Net -- Real Names, Real People, Real Info!
1998-2024 The Digital Video Information Network