Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Please assist with Batch Rendering script for Vegas 12

  • Please assist with Batch Rendering script for Vegas 12

    Posted by Roger Smith on January 10, 2015 at 3:53 am

    Hey all, I’m trying to get this script to work that I found. It’s free, so I assume it’s OK for me to get help to get it to work. I get errors when I execute it, and followed the instructions exactly. I’ll post the script, and a screen shot of the errors I’m receiving. All I want is batch rendering to work. I know there is commercial scripts out there that do tons of things, but I only need consecutive batch rendering for .veg files, nothing else. If I drag all the .veg files to a new Vegas window and render them as regions, it takes FOREVER! Each render of a hockey game .veg file is about 2:15 for an 1:15 hockey game. Rendering as described above takes over 12 hours for two .veg files, so I can’t do it that way. Any help is appreciated.

    Script:

    /**
    * This script renders all VEG projects that reside in the same folder
    * as the currently opened project (i.e., you choose the directory by opening any
    * VEG file in that directory).
    *
    * Created by John Meyer on January 28, 2010
    **/

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

    // Modify the following two lines to specify the render AND the template.

    //var rendererRE = /Video for Windows/;
    var rendererRE = /MainConcept AVC\/AAC/;
    // Put the template name betwee the ^ and $ characters to ensure that only the EXACT render name is used.
    // Capitalization matters!! Copy/paste from Render As Custom dialog to make sure name is correct.
    var templateRE = /^Internet HD 1080p CUDA$/;

    // Set this to a valid out directory or set it to null if you want the
    // output files to be created in the same directory as their project file.
    //var defaultOutputDir = "E:\\Football iPod Files\\";
    var defaultOutputDir =

    // Set the following variable to true if you want to allow the script
    // to overrwite existing rendered output files.
    var allowFileOverwrites = false;

    // The inputFileRegexp is used to filter the input files. For this script, it
    // will always be .veg.
    var inputFileRegexp = /.veg$/i;

    try {
    if ((null != defaultOutputDir) && !Directory.Exists(defaultOutputDir))
    throw "output directory does not exist: " + defaultOutputDir;

    // find the renderer and template
    var renderer : Renderer = FindRenderer(rendererRE);
    if (null == renderer)
    throw "failed to find renderer";
    var renderTemplate :RenderTemplate = FindRenderTemplate(renderer, templateRE);
    if (null == renderTemplate)
    throw "failed to find render template";

    // get file name extension that will be appended to each output file
    var rendererExt = renderer.FileExtension.substring(1);

    // Set up the array which will hold the list of all files in the project directory.
    var renderQueue = new Array();
    var queueIndex = 0
    var dir = Path.GetDirectoryName(Vegas.Project.FilePath);

    var fileEnum = new Enumerator(Directory.GetFiles(dir));

    // Go through all the files in the project directory and build a list of the
    // VEG files.
    while (!fileEnum.atEnd()) {
    var nextVeg = fileEnum.item();

    // skip files that don't end with the right extension
    if (null == nextVeg.match(inputFileRegexp)) {
    fileEnum.moveNext();
    continue;
    }

    renderQueue[queueIndex] = nextVeg;
    queueIndex++;
    fileEnum.moveNext();
    }

    // for each project file in the queue...
    var renderIndex = 0
    while (renderIndex < queueIndex) {
    // open the next project
    var vegFilename = renderQueue[renderIndex];
    if (!Vegas.OpenProject(vegFilename)) {
    throw &quot;failed to open project file: &quot; + vegFilename;
    }

    // compute the output directory
    var outputDir;
    if (null == defaultOutputDir) {
    outputDir = Path.GetDirectoryName(vegFilename);
    } else {
    outputDir = defaultOutputDir;
    }

    // create the output file name
    var outputName = Path.GetFileNameWithoutExtension(vegFilename);
    var outputFilename = outputDir + Path.DirectorySeparatorChar + outputName + rendererExt;
    if ((!allowFileOverwrites) &amp;&amp; File.Exists(outputFilename))
    throw &quot;file already exists: &quot; + outputFilename;

    // perform the render
    var renderStatus = Vegas.Render(outputFilename, renderTemplate);

    if (RenderStatus.Complete != renderStatus)
    throw &quot;failed to complete render: &quot; + outputFilename;

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

    function FindRenderer(rendererRegExp : RegExp) : Renderer {
    var rendererEnum : Enumerator = new Enumerator(Vegas.Renderers);
    while (!rendererEnum.atEnd()) {
    var renderer : Renderer = Renderer(rendererEnum.item());
    if (null != renderer.FileTypeName.match(rendererRegExp)) {
    return renderer;
    }
    rendererEnum.moveNext();
    }
    return null;
    }

    function FindRenderTemplate(renderer : Renderer, templateRegExp : RegExp) : RenderTemplate {
    var templateEnum : Enumerator = new Enumerator(renderer.Templates);
    while (!templateEnum.atEnd()) {
    var renderTemplate : RenderTemplate = RenderTemplate(templateEnum.item());
    if (renderTemplate.Name.match(templateRegExp)) {
    return renderTemplate;
    }
    templateEnum.moveNext();
    }
    return null;
    }


    Error window:

    John Rofrano replied 11 years, 4 months ago 2 Members · 6 Replies
  • 6 Replies
  • John Rofrano

    January 10, 2015 at 12:37 pm

    You named the file wrong. You named the file with a .cs extension which indicates that it’s a C# file. That is NOT C# code in that file, that’s JavaScript. Try changing the file extension to .js instead.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Roger Smith

    January 10, 2015 at 5:34 pm

    Thanks. I know absolutely nothing about scripting, coding, etc… I guess I’ll have to spend some time learning it if I can retire soon….

  • Roger Smith

    January 10, 2015 at 6:13 pm

    [John Rofrano] “You named the file wrong. You named the file with a .cs extension which indicates that it’s a C# file. That is NOT C# code in that file, that’s JavaScript. Try changing the file extension to .js instead.”

    Well, different set of errors, and a lot more.

  • John Rofrano

    January 10, 2015 at 11:29 pm

    I’m guessing that whatever web site you copied that script from actually corrupted the code by escaping illegal characters. I noticed things like &quot; instead of a real ”

    This code is never going to work until you get a clean copy.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Roger Smith

    January 10, 2015 at 11:35 pm

    Unfortunately that came right out of the zip file. I looked at it and it has the same characters… I’ve attached it if you want to look at it.

    8392_renderallvegfilesinadirectory.zip

  • John Rofrano

    January 10, 2015 at 11:43 pm

    [Roger Smith] “Unfortunately that came right out of the zip file. I looked at it and it has the same characters”

    Yup. Whoever created that zip file didn’t know what they were doing. That files is already corrupt. You would have to go through it and clean out all of the HTML markup manually.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy