I want my code should reset pan & crop as well as mask.
private void ResetPanCrop(Vegas vegas)
{
List<TrackEvent> selectedEvents = GetSelectedEvents(vegas); if (selectedEvents == null)
{ MessageBox.Show("No Event Selected.", "Upps!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
foreach (Track track in vegas.Project.Tracks)
{
if (track.IsVideo())
{
foreach (VideoEvent vEvent in track.Events)
{
if (vEvent.Selected)
{
VideoStream vs = (VideoStream)vEvent.ActiveTake.Media.Streams.GetItemByMediaType(MediaType.Video, vEvent.ActiveTake.StreamIndex);
int mHeight = vs.Height;
int mWidth = vs.Width;
// Clear existing keyframes, leaving only the first one
vEvent.VideoMotion.Keyframes.Clear();
// Add a new keyframe at the beginning
VideoMotionKeyframe kf = new VideoMotionKeyframe(Timecode.FromFrames(0));
vEvent.VideoMotion.Keyframes.Add(kf);
// Set default values for pan and crop settings
VideoMotionBounds mb = kf.Bounds;
mb.TopLeft = new VideoMotionVertex(0f, 0f);
mb.TopRight = new VideoMotionVertex(mWidth, 0f);
mb.BottomLeft = new VideoMotionVertex(0f, mHeight);
mb.BottomRight = new VideoMotionVertex(mWidth, mHeight);
kf.Bounds = mb;
kf.Rotation = 0.0;
}
}
}
}
}