Comments

BrianStanding wrote on 5/4/2005, 8:21 AM
You could do a mask and put it on the track above the track with your clips.
Or use Track Motion instead of Pan/Crop.

I think there are some scripts that do this, too. Check on the VASST site.
johnmeyer wrote on 5/4/2005, 9:26 AM
I don't know the author of this script, but I use it every day to set the aspect ratio of all selected events.

===============
// "Match Output Aspect" on all selected video events.
// No selection = ALL

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

var zero : int = 0;

function GetSelectionCount (mediaType)
{
var cTracks = Vegas.Project.Tracks.Count;
var cSelected = zero;
var ii;

for (ii = zero; ii < cTracks; ii ++)
{
var track = Vegas.Project.Tracks[ii];

if (track.MediaType == mediaType)
{
var eventEnum : Enumerator = new Enumerator(track.Events);

while ( ! eventEnum.atEnd() )
{
if (eventEnum.item().Selected)
{
cSelected ++;
}

eventEnum.moveNext();
}
}
}

return cSelected;
}

function GetActiveMediaStream (trackEvent : TrackEvent)
{
try
{
if ( ! trackEvent.ActiveTake.IsValid())
{
throw "empty or invalid take";
}

var media = Vegas.Project.MediaPool.Find (trackEvent.ActiveTake.MediaPath);

if (null == media)
{
throw "missing media";
}

var mediaStream = media.Streams.GetItemByMediaType (MediaType.Video, trackEvent.ActiveTake.StreamIndex);

return mediaStream;
}
catch (e)
{
//MessageBox.Show(e);
return null;
}
}

function MatchOutputAspect (keyframe : VideoMotionKeyframe, dMediaPixelAspect : double, dAspectOut : double)
{
var keyframeSave = keyframe;

try
{
var rotation = keyframe.Rotation;

// undo rotation so that we can get at correct aspect ratio.
//
keyframe.RotateBy (-rotation);

var dWidth = Math.abs(keyframe.TopRight.X - keyframe.TopLeft.X);
var dHeight = Math.abs(keyframe.BottomLeft.Y - keyframe.TopLeft.Y);
var dCurrentAspect = dMediaPixelAspect * dWidth / dHeight;
var centerY = keyframe.Center.Y;
var centerX = keyframe.Center.X;

var dFactor;

var bounds = new VideoMotionBounds(keyframe.TopLeft, keyframe.TopRight, keyframe.BottomRight, keyframe.BottomLeft);

if (dCurrentAspect < dAspectOut)
{
// alter y coords
dFactor = dCurrentAspect / dAspectOut;

bounds.TopLeft.Y = (bounds.TopLeft.Y - centerY) * dFactor + centerY;
bounds.TopRight.Y = (bounds.TopRight.Y - centerY) * dFactor + centerY;
bounds.BottomLeft.Y = (bounds.BottomLeft.Y - centerY) * dFactor + centerY;
bounds.BottomRight.Y = (bounds.BottomRight.Y - centerY) * dFactor + centerY;
}
else
{
// alter x coords
dFactor = dAspectOut / dCurrentAspect;

bounds.TopLeft.X = (bounds.TopLeft.X - centerX) * dFactor + centerX;
bounds.TopRight.X = (bounds.TopRight.X - centerX) * dFactor + centerX;
bounds.BottomLeft.X = (bounds.BottomLeft.X - centerX) * dFactor + centerX;
bounds.BottomRight.X = (bounds.BottomRight.X - centerX) * dFactor + centerX;
}

// set it to new bounds
keyframe.Bounds = bounds;

// restore rotation.
keyframe.RotateBy (rotation);

}
catch (e)
{
// restore original settings on error
keyframe = keyframeSave;
MessageBox.Show("MatchOuput: " + e);
}
}


var dWidthProject = Vegas.Project.Video.Width;
var dHeightProject = Vegas.Project.Video.Height;
var dPixelAspect = Vegas.Project.Video.PixelAspectRatio;
var dAspect = dPixelAspect * dWidthProject / dHeightProject;
var cSelected = GetSelectionCount (MediaType.Video);


var cTracks = Vegas.Project.Tracks.Count;
var ii;

for (ii = zero; ii < cTracks; ii ++)
{
var track = Vegas.Project.Tracks[ii];

if (! track.IsVideo())
{
continue;
}

var eventEnum : Enumerator = new Enumerator(track.Events);

while ( ! eventEnum.atEnd() )
{
var trackEvent : TrackEvent = eventEnum.item();

if ( !cSelected || trackEvent.Selected )
{
var mediaStream = GetActiveMediaStream (trackEvent);

if (mediaStream)
{
var videoStream = VideoStream (mediaStream);

var dMediaPixelAspect = videoStream.PixelAspectRatio;
var videoEvent = VideoEvent(eventEnum.item());
var keyframes = videoEvent.VideoMotion.Keyframes;

var cKeyframes = keyframes.Count;
var jj;

for (jj = zero; jj < cKeyframes; jj ++)
{
MatchOutputAspect (keyframes[jj], dMediaPixelAspect, dAspect);
}
}
}

eventEnum.moveNext();
}
}


Vegas.UpdateUI();
xjerx wrote on 5/4/2005, 9:35 AM
I've never used a script before...how do I use that?
fultro wrote on 5/4/2005, 10:11 AM
cut & paste this into notepad , save it with any name that you like, change the extension from .txt to .js, put it into your ProgramFiles/Sony Vegas/Scripts folder and reopen Vegas. Now it will show up in Vegas and will apply the project aspect ratio to any selected events
Anyway - it is the first time I have done such a thing - it worked for me - very useful....
jetdv wrote on 5/4/2005, 12:08 PM
The script was written by Sony. It can be found HERE along with a few other scripts and scripting information. Please rename it to "Matchaspect" instead of leaving the first "M" lowercase.

Other scripts also have this functionality built-in including both Excalibur 4 and Ultimate S. If you haven't used scripts at all, I would recommend you check them out.
garo wrote on 5/4/2005, 1:24 PM
Got that and see other scripts in the Script Menue Folder but how do I actually apply the script to an event?

//Garo
BrianStanding wrote on 5/4/2005, 1:54 PM
Tools|Script|Run Script