Add preset Pan/Crop event to keyframe

Effexer wrote on 12/25/2022, 7:08 AM

Hi, I'm trying to make a script to automatically change the first keyframe of some mediafiles to a pre-built Preset I've made, but I can't seem to get it to work for some reason.
Let's say I have a VideoEvent evnt
I first try to get its keyframes with VideoMotionKeyframes vKeyFrames = evnt.VideoMotion.Keyframes
Then I get the first keyframe with vKeyFrame[0]
All is good so far. But then if I try to change the preset with something such as
vKeyFrames[0].Preset = presetName;
I get the error: 'ScriptPortal.Vegas.VideoMotionKeyframe' does not contain a definition for 'Preset' and no extension method 'Preset' accepting a first argument of type 'ScriptPortal.Vegas.VideoMotionKeyframe' could be found (are you missing a using directive or an assembly reference?)
Even though the keyframes should have the Preset param.

Does anyone know of a way to solve my issue? Thank you in advance

Comments

jetdv wrote on 12/25/2022, 8:08 AM

You are correct. There is no "preset" under the VideoMotionKeyframe.

What you might try is to manually add that keyframe and write down all of the values. Then on each keyframe[0], set the values to the values used in your preset. You would need to calculate and then change the upper left, upper right, lower left, and lower right positions to match that preset.

jetdv wrote on 12/25/2022, 8:09 AM

Or, better yet, apply that preset and then use another script to READ those values so you don't have to calculate them.

Effexer wrote on 12/25/2022, 8:33 AM

Or, better yet, apply that preset and then use another script to READ those values so you don't have to calculate them.

Thank you jetdv, that elucidates some of my doubts. So there's no way to just copy a preset and I gotta modify the VideoMotionKeyframe params like Topleft, Topright etc ?
How would I go about reading those values from my preset? Is there an easy way to get to it or will I have to write it down manually?

jetdv wrote on 12/25/2022, 4:41 PM

Add your preset to the event and then using your script that gets "keyframe[0]", use a MessageBox.Show() to show the top left x/y, top right x/y etc... and then just write them down. Just show everything that you will change.

As you've seen "Preset" isn't an available option and it won't show up in Visual Studio (it will show as an error). Are you using Visual Studio to edit the scripts?

jetdv wrote on 12/25/2022, 5:02 PM

Under the "keyframe[0]", you can see Top Left X/Y, Top Right X/Y, Bottom Left X/Y, Bottom Right X/Y (which are all also found within the "Bounds".)

You can also see Center, Position, Rotation, Smoothness, and Type.

Under evnt.VideoMotion, you also have ScaleToFill.