How to name a region after it's asset?

jltzd wrote on 7/27/2004, 5:16 PM
Hello,

I am working on a batch ac3 export script to batch transcode thousands of ac3 files out of vegas5.

I'm pretty amateur hour when it comes to scripting but I've managed to hack some other people's scripts to get parts of what I need.

THe way I see it:

1. I drop all of the ac3 files into the timeline.

2. I run the script

- script creates regions around every clip named after the clip
- script normalizes
- script batch exports regions to ac3

I can use all of the help I can get, especially with getting the macro to name the regions after the source file. I'm assuming it's some kind of System.Object call...just don't know how to do it.

thanks in advance,

John H

Comments

jetdv wrote on 7/27/2004, 7:33 PM
You could try something like this:


MyTake = MyEvent.ActiveTake;
myregion.Label = Path.GetFileNameWithoutExtension(MyTake.MediaPath);
johnmeyer wrote on 7/28/2004, 8:51 AM
Here's a script I wrote a long time ago to convert all markers into regions. The region names are taken from the marker names. You could use the code fragment jetdv provided to name the regions using the asset name, rather than using the marker name.

===================
/**
* This script will convert markers to regions.
* The original markers are left intact.
*
* The script ignores all markers beyond the last event.
*
* By John Meyer 12/8/2003
*
**/

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

var MyRegion : Region;
var PrevMarker : Marker;
var RegionStart : Timecode;
var RegionEnd : Timecode;

try {

var markerEnum = new Enumerator(Vegas.Project.Markers); // Start going through all the markers
PrevMarker = markerEnum.item(); // Remember first marker

while (!markerEnum.atEnd()) { // Keep going until last marker

markerEnum.moveNext(); // Get next marker

if (markerEnum.atEnd()) { // If no more markers (we're almost finished),
RegionEnd = Vegas.Project.Length; // get timecode at end of project
}

else {
RegionEnd = markerEnum.item().Position; // Get timecode for current marker
}


RegionStart = PrevMarker.Position; // Regions starts at previous marker.
var RegionName = PrevMarker.Label; // Name the region using previous marker's name.

// The RegionExist function checks if a region already exists at this point.
if (!RegionExist(RegionStart.ToMilliseconds(),RegionEnd.ToMilliseconds() ) ) {
MyRegion = new Region(RegionStart,RegionEnd - RegionStart,RegionName);
Vegas.Project.Regions.Add(MyRegion); // Add the new region
}

if (markerEnum.atEnd()) break; // If out of markers, quit.

// If last marker is equal to or beyond the end of the project, stop here.
if ( Vegas.Project.Length.ToMilliseconds() <= markerEnum.item().Position.ToMilliseconds() ) {
break;
}

else {
PrevMarker = markerEnum.item(); // Remember this marker for next loop.
}

}

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


function RegionExist(dStart,dLength) : boolean {

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

while (!fmarkerEnum.atEnd()) {
var fRegion = fmarkerEnum.item();
var fRegionLength = fRegion.Length.ToMilliseconds();
var fRegionStart = fRegion.Position.ToMilliseconds();

if ( (dLength == fRegionLength) && (dStart == fRegionStart) ) {
return 1;
}
fmarkerEnum.moveNext();
}
return 0;
}
rcampbel wrote on 8/1/2004, 4:26 PM
Hi John H,

I just released a new version of the Veggie Toolkit with an update to the Capture Cutter tool that you should be able to use for batch conversions. You can get the details at:

http://www.peachrock.com/software/capturecutter.html#BatchRendering

It doesn't do the normalize, but all you have to do is select all of the events (right click on the first event in the timeline and then click on Select Event to End), then right click again and set the Normalize switch.

Let me know if this works for you.

Randall
akg wrote on 8/4/2004, 10:06 AM
Can that scripts
make text media that on time line
into the same (text)name to region or marker ??
rcampbel wrote on 8/4/2004, 11:54 AM
The script does not create any text media, but I am not sure exactly what you want to do. Are you wanting to create text media for a region in which the text of the text media is the same as the region name?

If so, there is currently no way in the API to modify paramaters of a plug-in.

Randall
jltzd wrote on 8/4/2004, 3:44 PM
Hello Randall,

I like your software, but when I hit start in Capture Cutter (after following the directions on the website) I get an "Output FIle Not Found. It may Have been Renamed By The Codec" error.

I am trying to batch convert wavs to ac3.

thanks,

John H
rcampbel wrote on 8/4/2004, 4:10 PM
Hi John,

I think that this is happening because Vegas can create .ac3 files, but it can't open them. After the render, I am adding the files to the Vegas media pool so that I can show them on the timeline. Are the ac3 files being created Ok in the output folder?

In retrospect, I think that the error message is a bit annoying, so I am going to look at reworking that a bit. I will work on this tonight.

Thanks for letting me know,

Randall
rcampbel wrote on 8/5/2004, 8:57 AM
John and I discovered that this problem was a small bug in Vegas 5.0b. If you try to render to a custom ac3 template immediately after starting Vegas, the files do not get created even though the render status is Complete. If you render first to a standard ac3 template, then render using the custom template, it works.

I have reported this problem to Sony.

Randall