Match Output Aspect Script exists?

Julius_ wrote on 7/30/2011, 9:02 AM
Hi,

I just finished editing a 1 hour long wedding (shot in SD, edited with NTSC DV 720X480 (not widescreen). Gave it to client who know wants it widescreen.

I can change the project settings to NTSC Widescreen but it doesn't apply it to the clips automatically. I can adjust each clip by selecting "Match Output Aspect", but with about 900 cuts, this will take forever. There must be a script somewhere to facilitate this, no?

Thanks
-Julius

Comments

altarvic wrote on 7/30/2011, 10:31 AM
go to http://vegasaur.com and install it. You can freely use it within 30 days.
Open project, select all events and run View > Extensions > Vegasaur > 1-Click Commands > Match Output Aspect
Chienworks wrote on 7/30/2011, 1:04 PM
Be prepared for lots of complaints about the tops of people's heads being cut off. I'm sure the original video wasn't shot with the cropping in mind.

It always astounds me how hung up so many people get over aspect ratio. Sheesh. They should just enjoy the video, however it is,
Former user wrote on 7/30/2011, 1:07 PM
Unless he is just stretching, in which case, the bride or bridegrooms will complain about the xtra weight. :)

Dave T2
Chienworks wrote on 7/30/2011, 1:22 PM
Split the difference ... moderately obese bride with part of the top of her head cut off! That'll be real popular.
Julius_ wrote on 7/30/2011, 2:20 PM
Thank you!!!!!
I downloaded it and it worked really great...yes I did have to check a few pics and clips to make sure the heads weren't cut off..Small adjustment..but it worked really well on about 95% of my clips...the problems found were:

-If you made two boxes side by side, on a few clips one box was larger than the other.
-The pics needed to be adjusted (no biggie, I only had 10
-I mostly stay in the safe area, so after going widescreen, the screen was still in the frame.

Great!! I just saved about a day's work...the downside is that I might buy this little tool.
PeterDuke wrote on 7/30/2011, 4:50 PM
"the bride or bridegrooms"

Perhaps bigamy is the way to go in China where there is a shortage of marriageable women. :)

(Sorry, I know you meant bridesmaids)
Former user wrote on 7/30/2011, 5:34 PM
yeah, you are right. Shows how long it has been since I was married.

Thanks
Dave T2
jetdv wrote on 7/31/2011, 5:41 AM
Here's a "MatchAspect.js" script from WAAAAAY back: In fact, it's so old that "SonicFoundry" will need to be changed to "Sony".


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

import System.Windows.Forms;
import SonicFoundry.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();

Julius_ wrote on 7/31/2011, 2:59 PM
Thanks JetDV... I actually found this in an old zip file I once had...and it came from your website. I just re-visited it because it was a great place that had everything in one place...and I loved those newsletters. I know it must of been tons of work and thanks for all that info. I will be checking it out again...and chance of re-starting the newsletters?

Julius_ wrote on 7/31/2011, 3:05 PM
Jetdv,

I ran the script and got this error:
C:\temp\match.js(38) : Variable 'TrackEvent' has not been declared
C:\temp\match.js(54) : Variable 'MediaType' has not been declared
C:\temp\match.js(65) : Variable 'VideoMotionKeyframe' has not been declared
C:\temp\match.js(85) : Variable 'VideoMotionBounds' has not been declared
C:\temp\match.js(147) : Expression must be a compile time constant
C:\temp\match.js(155) : Variable 'VideoStream' has not been declared
C:\temp\match.js(158) : Variable 'VideoEvent' has not been declared

I tried selecting the events, the clips...maybe it's not up to par with the latest version?? I also tried in Vegas 7 with same error.
onlyway wrote on 7/31/2011, 5:38 PM
if you have used v.9 or newer of vegas pro,
1st, change project properties to widescreen project, and move all media file to timeline then just click Tools > Scripting > Remove Letterboxing.

it's called to Match output aspect.

wish your success.

regards,
jacob kim
jetdv wrote on 8/1/2011, 10:26 AM
I just took the script, changed:

import SonicFoundry.Vegas;

to:

import Sony.Vegas;

and it ran fine in Vegas Pro 9 for me. I'd have to take it to a different machine to test in Vegas Pro 10.
Julius_ wrote on 8/1/2011, 10:54 AM
Great thanks..The script also works in V10 once you change:

import SonicFoundry.Vegas;

to:

import Sony.Vegas;

Thanks for your help,,and Onlyway too. great suggestion!!