I spent far too long getting this to work again because I forgot to transfer the script from one computer to another, and all of the web references to this technique are, shall we say, broken like a character on Battlestar Galactica. So for anyone else who might need this, I give you a Sony Vegas script to change the pixel aspect ratio of all images in your media pool, written in C#.
/**
* This script sets the Pixel Aspect Ratio of all images to be 0.9091.
*
* Author: Stephen Granade Date: 21 April 2008
**/
using System.Text.RegularExpressions;
using Sony.Vegas;
public class EntryPoint {
public void FromVegas(Vegas vegas) {
foreach (Media media in vegas.Project.MediaPool) {
Match m = Regex.match(media.FilePath, "(jpe?g|png|gif)");
if (m.Success) {
VideoStream vs = media.GetVideoStreamByIndex(0);
vs.PixelAspectRatio = 0.9091;
}
}
}
}


4 Comments
Hey this sounds extremely useful, but I tried this in Vegas 6 with a bunch of photos on my timeline but it gives the following error:
Compilation errors:
‘System.Text.RegularExpressions.Regex’ does not contain a definition for ‘match’
‘Sony.Vegas.Media’ does not contain a definition for ‘GetVideoStreamByIndex’
System.ApplicationException: Failed to compile.
at Sony.Vegas.CodeDomScriptManager.Compile()
at Sony.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)
Do you know a quick fix? I have zero experience with scripts in Vegas…
Cheers, Mirko
Sorry, Mirko, I don’t. I’m running 8 here.
Hi Stephen
This looks exactly what I need! But I need it to change the p.a.r. on a video file.
Could it be modified to work with a .MP4 file?
See link above for more info.
Also, do I need to compile it in Visual c#??
Thanks a lot,
You should be able to modify it to find .mp4 files instead of still images. Try changing “(jpe?g|png|gif)” to “mp4″ in the script. And Vegas 8 should do the compilation for you. You shouldn’t need to compile it yourself.