@jetdv Sir, please, when you have free time for this, how I solve this issue in the code below. I did a video trying to explain;
using System; using ScriptPortal.Vegas; namespace Test_Script { public class Class1 { public Vegas myVegas; public void Main(Vegas vegas) { myVegas = vegas; foreach (Track currentTrack in myVegas.Project.Tracks) { if (currentTrack.IsVideo()) { foreach (TrackEvent currentEvent in currentTrack.Events) { if (currentEvent.Selected) { Timecode targetLength = Timecode.FromSeconds(5); Timecode currentLength = currentEvent.Length; if (currentLength < targetLength) { double newPlaybackRate = currentLength.ToMilliseconds() / targetLength.ToMilliseconds(); Timecode offset = currentEvent.ActiveTake.Offset; Timecode newOffset = Timecode.FromMilliseconds(offset.ToMilliseconds() / newPlaybackRate); currentEvent.PlaybackRate = newPlaybackRate; currentEvent.ActiveTake.Offset = newOffset; currentEvent.Length = targetLength; foreach (TrackEvent audioEvent in currentEvent.Group) { if (audioEvent.IsAudio()) { audioEvent.PlaybackRate = newPlaybackRate; Timecode audioOffset = audioEvent.ActiveTake.Offset; Timecode newAudioOffset = Timecode.FromMilliseconds(audioOffset.ToMilliseconds() / newPlaybackRate); audioEvent.ActiveTake.Offset = newAudioOffset; audioEvent.Length = targetLength; } } } FixUnquantizedFrames(currentEvent); foreach (TrackEvent groupedEvent in currentEvent.Group) { if (groupedEvent.IsAudio()) { FixUnquantizedFrames(groupedEvent); } } } } } } } private void FixUnquantizedFrames(TrackEvent evt) { double frameRate = myVegas.Project.Video.FrameRate; double frameDurationMs = 1000.0 / frameRate; double startMs = evt.Start.ToMilliseconds(); evt.Start = new Timecode(Math.Round(startMs / frameDurationMs) * frameDurationMs); double lengthMs = evt.Length.ToMilliseconds(); evt.Length = new Timecode(Math.Round(lengthMs / frameDurationMs) * frameDurationMs); } } } public class EntryPoint { public void FromVegas(Vegas vegas) { Test_Script.Class1 test = new Test_Script.Class1(); test.Main(vegas); } }