MPEG2 Video & AC3 audio rendering simultaneously - how ?

jrr wrote on 6/1/2003, 8:45 PM
Am i missing something really obvious ????

I recently took up the special offer to get DVD Architect & the AC3 encoder upgrade for my Vegas 4.

I'm now attempting to render a music clip in Mpeg2 video and AC3 audio. Doesn't seem possible. When I pick the mainconcept video encoder, it also sets the audio encoder to be mpeg1 layer 2 audio.

The only way I can do it, is by encoding the video separately (as an elementary stream) and then the audio as AC3. Then use TMPGEnc to mux them !

I've gotta be missing something don't I ?!?!

TIA,

james

Comments

jetdv wrote on 6/1/2003, 9:31 PM
You have to render twice but you DON'T need TMPGenc. Render to MPEG-2 but NOT as an elementary stream (The DVD Architect presets render non-elementary streams that do not have audio although it doesn't hurt for the MPEG-2 file to have audio)

Then render the AC-3 file.

In DVDA, add the MPEG-2 file as the video file and the AC-3 file as the audio file (if named properly, the AC-3 file will automatically be used.)
johnmeyer wrote on 6/2/2003, 11:53 AM
You can use a script written by one of the people at SOFO. It will create both the MPEG2 and the AC3 files in one operation. I think this script is on the Vegas CD, but here it is again, in case you can't find it. Just save this in a folder with a file name that has the extension ".js" (e.g., "DVD Architects.js"). Select "Scripting" then "Run Script" from the Tools menu and select this script to run it. You can also assign this script to one of the shortcut keys so you can start it just by a single shortcut key combination.
==================================

/**
* The following script renders a project in two stages for use in DVD
* Architect. The first stage renders the video as MPEG-2 (NTSC),
* second renders the audio as either AC-3 or 48KHz Wave.
*
* Revision Date: Feb. 10, 2003
**/

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

var videoRendererRegexp = /MPEG-2/;
var videoTemplateRegexp = /DVD Architect NTSC video/;
var audioRendererRegexp;
var stereoTemplateRegexp = /Stereo/;
var surroundTemplateRegexp = /Surround/;
var fourtyEightKHzRegexp = /48/;
var audioTemplateRegexp;

try {

var renderStart = new Timecode();
var renderLength = Vegas.Project.Length;
if (Vegas.SelectionLength > new Timecode()) {
var msgBoxResult = MessageBox.Show("Render selected region only?", "Region Selected", MessageBoxButtons.YesNo);
if (msgBoxResult == DialogResult.Yes) {
renderStart = Vegas.SelectionStart;
renderLength = Vegas.SelectionLength;
}
}

var projDir, projName, videoOutputFile, audioOutputFile;

var projFile = Vegas.Project.FilePath;
if ((null == projFile) || (0 == projFile.length)) {
projDir = "E:\\My Video\\";
projName = "JHM";
} else {
projDir = Path.GetDirectoryName(projFile) + Path.DirectorySeparatorChar;
projName = Path.GetFileNameWithoutExtension(projFile);
}

videoOutputFile = projDir + projName + ".mpg";
videoOutputFile = ShowSaveFileDialog("MPEG-2 Files (*.mpg)|*.mpg", "Render Video File", videoOutputFile);
if (null == videoOutputFile)
throw "operation canceled";

var mpegRenderer = findRenderer(videoRendererRegexp);
if (null == mpegRenderer)
throw "failed to find MPEG-2 renderer";

var videoTemplate = findTemplate(mpegRenderer, videoTemplateRegexp);
if (null == videoTemplate)
throw "failed to find video template";

audioOutputFile = Path.GetDirectoryName(videoOutputFile) + Path.DirectorySeparatorChar + projName;
var audioFileFilter = "AC-3 Files (*.ac3)|*.ac3|Wave Files (*.wav)|*.wav"
audioOutputFile = ShowSaveFileDialog(audioFileFilter, "Render Audio File", audioOutputFile);
if (null == audioOutputFile)
throw "operation canceled";

var audioExtension = Path.GetExtension(audioOutputFile);
if (audioExtension == ".ac3") {
audioRendererRegexp = /AC-3/;
} else if (audioExtension == ".wav") {
audioRendererRegexp = /Wave.*Microsoft/;
} else {
throw "unknown file extension: " + audioOutputFile;
}

var audioRenderer = findRenderer(audioRendererRegexp);
if (null == audioRenderer)
throw "failed to find audio renderer";

if (audioExtension == ".wav") {
// just do 48KHz stereo.
audioTemplateRegexp = fourtyEightKHzRegexp;
} else {
// if the project is surround, use the surround template,
// otherwise use the stereo template.
var audioProperties : SonicFoundry.Vegas.ProjectAudioProperties = SonicFoundry.Vegas.ProjectAudioProperties(Vegas.Project.Audio);
if (audioProperties.MasterBusMode == AudioBusMode.Surround)
audioTemplateRegexp = surroundTemplateRegexp;
else
audioTemplateRegexp = stereoTemplateRegexp;
}

var audioTemplate = findTemplate(audioRenderer, audioTemplateRegexp);
if (null == audioTemplate)
throw "failed to find audio template";

var renderStatus = Vegas.Render(videoOutputFile, videoTemplate, renderStart, renderLength);
if (renderStatus != RenderStatus.Complete)
throw "render not complete";

var renderStatus = Vegas.Render(audioOutputFile, audioTemplate, renderStart, renderLength);
if (renderStatus != RenderStatus.Complete)
throw "render not complete";

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

// find a renderer that matches the given regular expression.
function findRenderer(re) {
var rendererEnum = new Enumerator(Vegas.Renderers);
while (!rendererEnum.atEnd()) {
var renderer = rendererEnum.item();
if (null != renderer.FileTypeName.match(re)) {
return renderer;
}
rendererEnum.moveNext();
}
return null;
}

// find a render template that matches the given regular expression.
function findTemplate(renderer, re) {
var templateEnum = new Enumerator(renderer.Templates);
while (!templateEnum.atEnd()) {
var template = templateEnum.item();
if (null != template.Name.match(re)) {
return template;
}
templateEnum.moveNext();
}
return null;
}

// an example filter: "PNG File (*.png)|*.png|JPEG File (*.jpg)|*.jpg"
function ShowSaveFileDialog(filter, title, defaultFilename) {
var saveFileDialog = new SaveFileDialog();
if (null == filter) {
filter = "All Files (*.*)|*.*";
}
saveFileDialog.Filter = filter;
saveFileDialog.Title = title;
saveFileDialog.CheckPathExists = true;
saveFileDialog.AddExtension = true;
if (null != defaultFilename) {
var initialDir = Path.GetDirectoryName(defaultFilename);
if (Directory.Exists(initialDir)) {
saveFileDialog.InitialDirectory = initialDir;
}
saveFileDialog.DefaultExt = Path.GetExtension(defaultFilename);
saveFileDialog.FileName = Path.GetFileName(defaultFilename);
}
if (System.Windows.Forms.DialogResult.OK == saveFileDialog.ShowDialog()) {
return Path.GetFullPath(saveFileDialog.FileName);
} else {
return null;
}
}



jrr wrote on 6/3/2003, 12:42 PM
Thank you - I didn't get the CD, just the downloadable version. The script above isn't in the downloadable script examples.

Shipping to Australia is ridiculously expensive. I didn't even bother to get the 'free' Vision Series 1 & 2 because SoFo only use blasted expensive couriers to ship CDs, and they are over the top compared to other forms of AirMail postage.

Still - I am thinking I should have paid the postage for the Vision Series. Ah well - too late now ;-)

Thanks for your help.

I primarily work in PAL here in Australia. I presume I would just change the line: -
var videoTemplateRegexp = /DVD Architect NTSC video/;
to
var videoTemplateRegexp = /DVD Architect PAL video/;

regards,

jr