I have two scripts, the first script automatically assigns all frames to 100 frames per second and slows them down by 4 times the main thing is that it automatically determines these frames on the timeline, and they do not need to be selected minus script - I can’t make them stretch along the entire length - I have to do it manually
//****************************************************************************
//* Program: Convert59to29Media.cs
//* Author: John Rofrano
//* Description: This script changes the playback rate of 59.94p media to 27.97
//* Created: July 8, 2017
//*
//* Copyright: (c) 2017, John J. Rofrano, All Rights Reserved
//****************************************************************************
using System;
using System.Collections;
using System.Windows.Forms;
// Uncomment for Sony Vegas Pro
//using Sony.Vegas;
// Comment out for MAGIX Vegas Pro
using ScriptPortal.Vegas;
class EntryPoint
{
public void FromVegas(Vegas vegas)
{
int counter = 0;
try
{
foreach (Track track in vegas.Project.Tracks)
{
if (!track.IsVideo()) continue;foreach (VideoEvent videoEvent in track.Events)
{
VideoStream videoStream = videoEvent.ActiveTake.MediaStream as VideoStream;
decimal frameRate = Math.Round((decimal)videoStream.FrameRate, 2);
// only affect 59.94fps media
if (frameRate == 100.00m)
{
//videoEvent.AdjustPlaybackRate(0.25, true);
videoEvent.PlaybackRate = 0.25;
videoEvent.ResampleMode = VideoResampleMode.Disable;
counter++;
}
}
}// let the user know we are done
MessageBox.Show(String.Format("{0} events changed", counter), "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
the second script - it can automatically stretch frames to a long length, but my frames need to be spread manually, and in the first script they are automatically executed and I want how to combine two scripts into one so that it works like this when the script is launched, all frames at a speed of 100 frames per second are automatically enlarged on the timeline and automatically stretched along their length (since they have slowed down 4 times)
using System;
using System.Collections.Generic;using ScriptPortal.Vegas; // "ScriptPortal.Vegas" for Magix Vegas Pro 14 or above, "Sony.Vegas" for Sony Vegas Pro 13 or below
namespace Test_Script
{
public class Class
{
public Vegas myVegas;
public void Main(Vegas vegas)
{
myVegas = vegas;foreach (Track myTrack in myVegas.Project.Tracks)
{
if (myTrack.IsVideo())
{
List<VideoEvent> eventList = new List<VideoEvent>();
foreach (TrackEvent evnt in myTrack.Events)
{
if (evnt.Selected)
{
eventList.Add((VideoEvent)evnt);
}
}if (eventList.Count == 0)
{
continue;
}Timecode offset = Timecode.FromNanos(0);
for (int i = 0; i < eventList.Count - 1; i++)
{
if (eventList[i+1].IsGrouped)
{
Timecode tc = eventList[i+1].Start - eventList[i].End;
foreach (TrackEvent ev in eventList[i+1].Group)
{
ev.Start -= tc;
}
}
else
{
eventList[i+1].Start = eventList[i].End;
}
}foreach (VideoEvent vEvent in eventList)
{
double rateSave = vEvent.PlaybackRate;
double rate = myVegas.Project.Video.FrameRate / ((VideoStream)vEvent.ActiveTake.MediaStream).FrameRate;
if (rate < 0.6) {
rate *= 1;
}
Timecode lengthSave = vEvent.Length;
vEvent.Length = Timecode.FromFrames((long)(Math.Floor(lengthSave.Nanos * myVegas.Project.Video.FrameRate * rateSave / rate / 10000000)));
vEvent.PlaybackRate = rate;vEvent.Start += offset;
if (vEvent.IsGrouped)
{
foreach (TrackEvent groupEvent in vEvent.Group)
{
if (groupEvent == vEvent)
{
continue;
}
groupEvent.Start += offset;
rateSave = groupEvent.PlaybackRate;
groupEvent.PlaybackRate = vEvent.PlaybackRate;
groupEvent.Length = Timecode.FromNanos((long)(groupEvent.Length.Nanos * rateSave / groupEvent.PlaybackRate));
}
}
offset += vEvent.Length - lengthSave;
}
}
}
}
}
}public class EntryPoint
{
public void FromVegas(Vegas vegas)
//public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args)
{
Test_Script.Class test = new Test_Script.Class();
test.Main(vegas);
}
}