Picture Aspect Script

taliesin wrote on 6/21/2004, 12:34 PM
Over on the other forum we discussed a problem with importing pictures into Vegas 5. It's about a PAL project and pictures which are smaller in width and height than PAL sizes. Now Vegas does stretch those pics and there is no way to automatically prevent Vegas from doing this.

Scripting could solve this problem in an easy way.

Now those ones who experienced this problem are not able to write scripts. So we ask for help here. Could somebody do us a favour to write a script which does:

- Affect selected Events
- Apply Pan/Crop onto them
- Set Pan/Crop value of width to 787 and height to 576

Such a script would help us to restore all imported pics to original size just by one key-stroke.

Thanks for any help.

Marco

Comments

jetdv wrote on 6/21/2004, 2:13 PM
Marco,

Not sure if this will do exactly what you are looking for but it might be a good starting point for you:


/**
* Manually change Pan/Crop to 787x576
*
* Written By: Edward Troxel
* www.jetdv.com/tts
* Modified: 06-21-2004
* Copyright 2004 - JET Digital Video
* www.jetdv.com/tts
**/

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



try {
var trackEnum = new Enumerator(Vegas.Project.Tracks);
while (!trackEnum.atEnd()) {
var track : Track = Track(trackEnum.item());
var eventEnum = new Enumerator(track.Events);
while (!eventEnum.atEnd()) {
var evnt : TrackEvent = TrackEvent(eventEnum.item());

if (evnt.Selected) {
var keyframes = vevnt.VideoMotion.Keyframes;
var keyframe = keyframes[0];

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

var AdjY = bounds.TopLeft.Y;
var AdjX = bounds.TopLeft.X;

//Resize the image as specified
bounds.TopLeft.Y = AdjY;
bounds.TopRight.Y = AdjY;
bounds.BottomLeft.Y = 576 + AdjY;
bounds.BottomRight.Y = 576 + AdjY;

bounds.TopLeft.X = AdjX;
bounds.TopRight.X = 787 + AdjX;
bounds.BottomLeft.X = AdjX;
bounds.BottomRight.X = 787+ AdjX;

// set it to new bounds
keyframe.Bounds = bounds;
}
eventEnum.moveNext();
}
trackEnum.moveNext();
}
} catch (e) {
MessageBox.Show(e);
}

taliesin wrote on 6/21/2004, 3:07 PM
Thanks.

Is following line correct?

"var keyframes = vevnt.VideoMotion.Keyframes;"

I think there might be a typo ("evnt" instead of "vevnt") but except of this there seems to be an issue with an object type there.

Marco
jetdv wrote on 6/21/2004, 5:45 PM
Yep, left out one line of code:

var vevnt = VideoEvent(evnt);

(That's what I get for quickly throwing it together and NOT testing it at all.)
taliesin wrote on 6/22/2004, 4:29 AM
It works now. We're trying to add another function for our personal use but overall your script is exactly what we were looking for.

Thank you a lot!

Marco

jetdv wrote on 6/22/2004, 6:14 AM
Just reply to my other e-mail if I can help.