Batch Render - RegionName

askSteve wrote on 10/11/2007, 3:57 PM
1. My qustion is how do I get my Regions Names to be included with the Batch Render in Vegas 8?

I get everything else but the Region name.

If someone could help me modify "Batch Render.cs" that would be great!

2. Or... I've tried to use this: RegionName - which works great in Vegas 7 but in Vegas 8 it's gone... any ideas?

Thanks to whomever solves this for me!

Steve

Comments

ForumAdmin wrote on 10/12/2007, 6:54 AM
If you need to adjust how files are named in the Batch Render script,
you will modify the lines of code that determine the file name. In
the case of rendering regions, these are the lines you need to change:


String regionFilename = String.Format("{0}[{1}]{2}",
filename,
regionIndex.ToString(),
renderItem.Extension);


You were not very specific about exactly how you want the files to be
named. If you want to use the region label instead of the region
index, try this:


String regionFilename = String.Format("{0}[{1}]{2}",
filename,
FixFileName(region.Label),
renderItem.Extension);


If you want the files to have exactly the same name as your regions:


String regionFilename = Path.Combine(outputDirectory,
String.Format("{0}{1}",
FixFileName(region.Label),
renderItem.Extension));



The problem with these changes is it is too easy to end up with files that
have the same name. But, with care, you can use the script this way.

For some background on the methods used here, the Path.Combine method
combines a directory string and a file name into a single path
string. This method is smart about adding directory separators when
needed. For example:


Path.Combine("C:\\renders", "My File.avi") ==> "C:\\renders\\My File.avi"


The String.Format method basically allows you to construct a string
from different parts. For full details, refer to this MSDN page:

http://msdn2.microsoft.com/en-us/library/txafckwd.aspx
Jessariah67 wrote on 10/15/2007, 7:02 AM
I replaced the code block and get this message:

E:\Program Files\Sony\Vegas Pro 8.0\Script Menu\Batch Render.cs(84) : The name 'region' does not exist in the current context
E:\Program Files\Sony\Vegas Pro 8.0\Script Menu\Batch Render.cs(91) : A local variable named 'regionFilename' cannot be declared in this scope because it would give a different meaning to 'regionFilename', which is already used in a 'parent or current' scope to denote something else
E:\Program Files\Sony\Vegas Pro 8.0\Script Menu\Batch Render.cs(101) : The name 'filename' does not exist in the current context
E:\Program Files\Sony\Vegas Pro 8.0\Script Menu\Batch Render.cs(110) : The name 'filename' does not exist in the current context

Any help would be appreciated. Thanks.
ForumAdmin wrote on 10/15/2007, 9:07 AM
It looks like you have replaced the wrong lines of code. The examples provided above are meant to replace only the lines in the first code block... these lines are within the inner-loop that renders regions.

Jessariah67 wrote on 10/15/2007, 9:39 AM
That Did it - Thanks
Skaven252 wrote on 1/11/2008, 7:19 AM
Thanks, this change was very helpful. I work with video game voiceovers, and find it convenient to keep the whole set of voiceovers of one character in one Vegas project. Rendering them all in a batch with proper names (from the regions) made it all much faster!

Another feature I would appreciate would be the ability to either:
A) Skip existing files or;
B) Specify which regions within the project you want to batch render (for example, only the regions within the loop region)

... because currently the script stops if a file already exists, and there's no way to batch render more selectively, other than by deleting all the other regions temporarily.

How could this be implemented? Thanks!

(Thought: to make it faster, I presume it's optimal to perform the file check *before* rendering the file)
ForumAdmin wrote on 1/11/2008, 11:57 AM

To skip files that already exist, change line of code near the top of
the DoRender function to just return rather than throw an exception:


// make sure the file does not already exist
if (!OverwriteExistingFiles && File.Exists(filePath)) {
// throw new ApplicationException("File already exists: " + filePath);
return;
}


To skip files that are not within the loop region, add another check
just below the lines above. This will return if the render region is not
within the loop region:


// make sure the render region is within the loop region
Timecode loopStart = myVegas.Transport.LoopRegionStart;
Timecode loopEnd = loopStart + myVegas.Transport.LoopRegionLength;
Timecode end = start + length;
if ((start >= loopStart) && (end <= loopEnd)) {
return;
}


Skaven252 wrote on 1/14/2008, 1:29 AM
Thank you very much! This helps me a lot. :)
Skaven252 wrote on 1/14/2008, 4:39 AM
I tried making the above changes to the script, but I got the following errors:

"
An object of a type convertible to 'Sony.Vegas.RenderStatus' is required
'Sony.Vegas.Vegas' does not contain a definition for 'Transport'
'Sony.Vegas.Vegas' does not contain a definition for 'Transport'
An object of a type convertible to 'Sony.Vegas.RenderStatus' is required

System.ApplicationException: Failed to compile.
at Sony.Vegas.CodeDomScriptManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)
"

I'm using Vegas 6.0d. Is the script perhaps using commands that are not available in 6.0?
JohnnyRoy wrote on 1/14/2008, 5:13 AM
> I'm using Vegas 6.0d. Is the script perhaps using commands that are not available in 6.0?

Yes, the Transport is a Vegas 8 object. You need to modify the BatchRender script that came with Vegas 6. Just search for "regionFilename" and you'll find it on line 97.

~jr
ForumAdmin wrote on 1/14/2008, 10:46 AM
For Vegas 6, rather than:


myVegas.Transport.LoopRegionStart
myVegas.Transport.LoopRegionLength


you can use:


myVegas.SelectionStart
myVegas.SelectionLength


Also, change both return statements to:


return RenderStatus.OK;

Skaven252 wrote on 1/22/2008, 6:08 AM
Sorry for the delay. And thanks for all your help. :) Here's an update: we've now upgraded to Vegas Pro 8, and I started afresh from the original Batch Render script that comes with the installation.

I made two changes as explained in this thread: "Append Region label to filename", and "make sure region is within selection", but I get the following error message on compile:

(136) : An object of a type convertible to 'Sony.Vegas.RenderStatus' is required

If I change the return message after the selection check to:


return RenderStatus.OK;


... I get this error message:

(136 - message missing) : 'Sony.Vegas.RenderStatus' does not contain a definition for 'OK'

Have I perhaps put the "region within selection check" in the wrong place? Here's what the section of code in questio looks like after the change I made:


...
// make sure the file does not already exist
if (!OverwriteExistingFiles && File.Exists(filePath)) {
throw new ApplicationException("File already exists: " + filePath);
}

// make sure the render region is within the loop region
Timecode loopStart = myVegas.Transport.LoopRegionStart;
Timecode loopEnd = loopStart + myVegas.Transport.LoopRegionLength;
Timecode end = start + length;
if ((start >= loopStart) && (end <= loopEnd)) {
return RenderStatus.OK;
}
...

jetdv wrote on 1/22/2008, 6:44 AM
How about:

RenderStatus.Complete