www.jetdv.com Forum Index Edward Troxel
Vegas Scripting and Newsletters
Home of Excalibur and Montage Magic
 
 FAQ   Search   Memberlist   Usergroups   Register   Profile 
 Log in to check your private messagesLog in to check your private messages   Log inLog in 

Batch render Script - Render Regions modification
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Free Scripts
View previous topic :: View next topic  
Author Message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Wed Jan 23, 2008 5:08 pm    Post subject: Batch render Script - Render Regions modification Reply with quote

Many people want the Batch Render script included with Vegas to also be able to render regions and name those regions based on the region label instead of a generic "1", "2", ... etc.

Here's a modified version for both Vegas 7 and Vegas 8 of the Batch Render script that will name the files for the region name.

Vegas 7: http://www.jetdv.com/scripts/BatchRender-Regions7.cs
Vegas 8: http://www.jetdv.com/scripts/BatchRender-Regions.cs
Back to top
View user's profile Send private message Send e-mail
TheHappyFriar



Joined: 26 Nov 2004
Posts: 447

PostPosted: Wed Jan 23, 2008 5:41 pm    Post subject: Reply with quote

THANK YOU!
Back to top
View user's profile Send private message Visit poster's website
kolsky



Joined: 23 Jan 2008
Posts: 1

PostPosted: Wed Jan 23, 2008 11:04 pm    Post subject: Reply with quote

thanks from me as well.. i noticed it crashes on multiple output but works great with single media output.
Back to top
View user's profile Send private message
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Thu Jan 24, 2008 3:15 am    Post subject: Reply with quote

In my testing, I also saw that it crashes if it tries to create a file a second time. That could be remedied but I didn't write the original version. It wouldn't take much to fix, though.
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Wed Sep 03, 2008 10:40 am    Post subject: also Path? Reply with quote

Hi,
I use the Script "JHM_Create_Regions_From_Event_File_Names.js" to create Regions with Clipname.
Then I use "BatchRender-Regions.cs" to render out the Clips with the Region name as file name.
I have 2 Questions:
1. is it possible to have also the filepath in the region name?
2. is it possible to use this path from this region name as render path in "BatchRender-Regions.cs"

Many thanks for your advice,

Tobias.
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Wed Sep 03, 2008 12:17 pm    Post subject: Reply with quote

Possible? Yes. But the script would have to be modified for that. Plus, there'd be no checks to verify that the folder already exists.
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Wed Sep 03, 2008 3:08 pm    Post subject: Reply with quote

I guessed it... could would you do or tell me how to do this...?

Maybe the two script could be combined?

I assume that there will be an error if the folder does not exist?

Thank you,

Tobias.
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Wed Sep 03, 2008 4:30 pm    Post subject: Reply with quote

Here's the line you'd need to change:

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

Are you going to include the extension in the label name as well as the path? I'm assuming NOT so you could use something like:

String regionFilename = region.Label + renderItem.Extension;

This is assuming that you don't have any invalid characters. I did not add a "FixFileName" command as that would eliminate the backslashes in your file path.
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Thu Sep 04, 2008 12:49 pm    Post subject: Reply with quote

Hi,
I changed the lines in the "BatchRender-Regions.cs". the result is that the file name is "Untitled_MainConcept MPEG-1_VCD PAL[0].mpg" in the bin that iwas selected in the batch render dialog.
The filename should have been "P1130060.mpg".

Maybe I misunderstand your description, but shouldn't the directory of the source clip be put in the Region name first?

What I want is:
I have a timeline with AVIs or BMPs or m2vs from different bins.
I want e.g. a mpg1 of each event in the timeline rendered to the bin where each original AVI or BMP or m2v of this timeline is.

So I thought that I 1. run a modified "JHM_Create_Regions_From_Event_File_Names.js" to get the original filepath + filename into the region name.
And 2. render the files using "BatchRender-Regions.cs".

Tobias.
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Thu Sep 04, 2008 1:17 pm    Post subject: Reply with quote

If you change those four lines to this single line:

String regionFilename = region.Label + renderItem.Extension;

as mentioned above it should do exactly what you want. All it does is take the region label and use that as the file name and then adds the proper extension.
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Thu Sep 04, 2008 1:21 pm    Post subject: Reply with quote

Hi and thank you.
But how do I get the Path to the region.Label ?
And could it work that this is used as destination path for render it out?
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Thu Sep 04, 2008 1:24 pm    Post subject: Reply with quote

Your previous post indicated you were using another script "to get the original filepath + filename into the region name" - so I assumed that part was already done. So are you looking for the changes to the other script?
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Thu Sep 04, 2008 2:22 pm    Post subject: Reply with quote

Hi. Yes, it's this one. But it's not putting the path into the region label. And I don't know if (even if this other script would put it in - maybe could also help me doing this) I could use that path as destination directory for the other script.

Thankyou again!

The other script:

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

var evnt : TrackEvent;
var myRegion : Region;
var RegionName : String;


try {

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

var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
evnt = TrackEvent(eventEnum.item());
var MyFilePath = evnt.ActiveTake.MediaPath;
var extFileName = Path.GetFileName(MyFilePath);
var baseFileName = Path.GetFileNameWithoutExtension(extFileName); // Media file name for this event

var StartTime = evnt.Start;
var LengthTime = evnt.Length;

if (evnt.FadeOut.Length.Nanos > 0) {
LengthTime = LengthTime - evnt.FadeOut.Length; // Eliminates region overlaps at crossfades.
}


// if (evnt.Selected) { // Add this IF statement, and ending brace, to only add regions for SELECTED events.

// The RegionExist function checks if a region already exists at this point.
if (!RegionExist(StartTime.ToMilliseconds(),LengthTime.ToMilliseconds() ) ) {
myRegion = new Region(StartTime,LengthTime,baseFileName); //Insert a region over this event
Vegas.Project.Regions.Add(myRegion);
}

// } // End if evnt.Selected

eventEnum.moveNext();
} // End while (!eventEnum.atEnd()

} 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 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;
}
Back to top
View user's profile Send private message Visit poster's website
Edward Troxel
Site Admin


Joined: 14 Jul 2004
Posts: 5475

PostPosted: Thu Sep 04, 2008 3:03 pm    Post subject: Reply with quote

You should be just getting the file name right now. It's being determined by this line:

var baseFileName = Path.GetFileNameWithoutExtension(extFileName);

You would need to change that line to read something like:

var baseFileName = Path.GetFullPath(MyFilePath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(extFileName);
Back to top
View user's profile Send private message Send e-mail
toboda



Joined: 13 Feb 2007
Posts: 23
Location: germany

PostPosted: Thu Sep 04, 2008 3:18 pm    Post subject: Reply with quote

Looks good: the full path is in the region lable.
After starting the modified (the 4 lines -> "String regionFilename = region.Label + renderItem.Extension;") "BatchRender-Regions.cs" and selecting "render regions" I get an error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Directory does not exist: 'D:\unsere Dateien\P1130064.JPG'
at Sony.Vegas.Vegas.ValidateDirectoryString(String path)
at Sony.Vegas.Vegas.ValidateOutputFile(String path)
at Sony.Vegas.Vegas.Render(String outputFile, RenderTemplate renderTemplate, Timecode start, Timecode length)
at EntryPoint.DoRender(String filePath, RenderItem renderItem, Timecode start, Timecode length)
at EntryPoint.DoBatchRender(ArrayList selectedTemplates, String basePath, RenderMode renderMode)
at EntryPoint.FromVegas(Vegas vegas)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sony.Vegas.ScriptHost.ScriptManager.Run(Assembly asm, String className, String methodName)
at Sony.Vegas.ScriptHost.CodeDomScriptManager.Run()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.jetdv.com Forum Index -> Free Scripts All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.11 © 2001, 2002 phpBB Group