VEGAS Pro Scripts Collections | SHARE YOUR SCRIPT HERE !!

iEmby wrote on 5/9/2024, 2:05 PM

This thread is dedicated to Only VEGAS Pro SCRIPTS.

so if you have created any script which can be helpful for VEGAS Users.

then share it here.

Conditions.

  • Scripts shared here should be Free to Use & Free To Share.
  • Sharing code or not is your decision.
  • Share a readme or explain properly, If you have something complex in your script.
  • If possible share a .cs or .dll file in a google drive or permanent available link.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Comments

iEmby wrote on 5/9/2024, 2:11 PM

IMPROVED & UPDATED !! BATCH RENDER Script Is Here! Download It. Test It. Share It

What I Able to Improve in This Script:

  1. Modern Icon & Improved Interface
  2. For VEGAS Pro 15 And Next Versions.
  3. Will Render Project, Selection, Regions (Default Feature)
  4. Will Render Regions by Using Regine Label as File Names.
  5. If No Region Label Is Existing. It Will Render by Naming Regions As 'Region-1' 'Region-2' ------- Onwards.
  6. Will Ask You for Crosscheck Rendering Information like Template, Rendering Mode, Duration and Selection Range and Output File Name.
  7. Will Not Work on Unsaved Fresh Project. It will Ask to Save Project First with Save Button. After saving project, script will run automatically.
  8. If You Was Not Willing to Save Project, You Can Press NO. It Will Save Project in a Temporary Projects Folder at Desktop.
  9. Will Keep All Renders in a Folder Named 'Renders' At the Same Location Where Project Is Saved. (This Folder Will Be Automatically Created)
  10. Will Render Output File in Project and Selection Mode with Same Name as Project Name Is.
  11. Will Save a Backup File of The Project Before Start Rendering, in a Folder Named 'Backups' which will be automatically created if not exists.
  12. If file is already existed, then it will give you options 'Overwrite' and 'Keep Both'. if 'Keep Both' selected then it will give it a name i.e. Existing File Name + count number starting from 1 in an incremented counter manner.

So, Download It. Share Your Thoughts on This. Enjoy.

https://drive.google.com/drive/folders/1ft0rZpcBhGatTw5sc2t18z0ACQAXWsu_?usp=sharing

Note: As at mid August 2024 above link no longer working. New link below

https://drive.google.com/drive/folders/16X76Lj2n7sutKolw7Y-aQuqliQimqGNB

Note: Paste Both Files Into 'Script Menu' In Your VEGAS Pro's Program Directory.

Last changed by EricLNZ on 9/9/2024, 8:30 PM, changed a total of 2 times.

Reason: Correction

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 6/13/2024, 1:57 PM

Match Output Aspects: Match the aspect ratio of output.

Does this allow users to choose whether to crop or not?
 

Not actually.. but thanks its good suggestion.

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/7/2024, 1:21 PM

Script For Swapping Two Same Length Video Events Between Different Tracks

using ScriptPortal.Vegas;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        // Ensure exactly two video events are selected
        List<TrackEvent> selectedEvents = new List<TrackEvent>();
        foreach (Track track in vegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected && trackEvent.IsVideo())
                {
                    selectedEvents.Add(trackEvent);
                }
            }
        }

        if (selectedEvents.Count != 2)
        {
            MessageBox.Show("Please select exactly two video events.");
            return;
        }

        // Ensure the selected events are on different tracks and have the same length
        TrackEvent event1 = selectedEvents[0];
        TrackEvent event2 = selectedEvents[1];

        if (event1.Track == event2.Track)
        {
            MessageBox.Show("Selected events must be on different tracks.");
            return;
        }

        if (event1.Length != event2.Length)
        {
            MessageBox.Show("Selected events must be of the same length.");
            return;
        }

        Track track1 = event1.Track;
        event1.Track = event2.Track;
        event2.Track = track1;
    }
}

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Gid wrote on 7/9/2024, 2:07 AM

Match Output Aspects: Match the aspect ratio of output.

Does this allow users to choose whether to crop or not?
 


@lan-mLMC I've got one of each if you're interested? Or maybe you're just asking about this 'Scripts Collections'

I think the cropping one is in the list by default, I can't remember.

This is Match Output without cropping

using System;
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Drawing;
using System.Runtime;
using System.Xml;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            float scrWidth = myVegas.Project.Video.Width;
            float scrHeight = myVegas.Project.Video.Height;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            MatchAspect(evnt);

                            VideoEvent videoEvent = evnt as VideoEvent;
                            VideoMotionKeyframes keyframes = videoEvent.VideoMotion.Keyframes;
                            int cKeyframes = keyframes.Count;
                            for (int jj = cKeyframes - 1; jj >= 0; jj--)
                            {
                                VideoMotionKeyframe thisKeyframe = keyframes[jj] as VideoMotionKeyframe;

                                float dWidth = Math.Abs(thisKeyframe.TopRight.X - thisKeyframe.TopLeft.X);
                                float dHeight = Math.Abs(thisKeyframe.BottomLeft.Y - thisKeyframe.TopLeft.Y); ;

                                MediaStream mediaStream = GetActiveMediaStream(videoEvent);
                                VideoStream videoStream = mediaStream as VideoStream;
                                VideoOutputRotation vRotation = videoStream.Rotation;

                                float dFullHeight = videoStream.Height;
                                float dFullWidth = videoStream.Width;
                                if ((vRotation == VideoOutputRotation.QuarterTurnClockwise) || (vRotation == VideoOutputRotation.QuarterTurnCounterclockwise))
                                {
                                    dFullHeight = videoStream.Width;
                                    dFullWidth = videoStream.Height;
                                }

                                float pwid = 0.0F;
                                float wpwid = 0.0F;
                                bool smaller = false;

                                if (dFullHeight > scrHeight)
                                {
                                    pwid = dFullHeight / dHeight * 100;
                                }
                                else
                                {
                                    pwid = dHeight / dFullHeight * 100;
                                    smaller = true;
                                }

                                if (dFullWidth > scrWidth)
                                {
                                    smaller = false;
                                    wpwid = dFullWidth / dWidth * 100;
                                }
                                else
                                {
                                    wpwid = dWidth / dFullWidth * 100;
                                }

                                if (wpwid > pwid && !smaller)
                                {
                                    pwid = wpwid;
                                }
                                if (wpwid < pwid && smaller)
                                {
                                    pwid = wpwid;
                                }

                                ScaleKeyframe(thisKeyframe, pwid, 0);
                            }
                        }
                    }
                }
            }
        }

        public void MatchAspect(TrackEvent trackEvent)
        {
            float dWidthProject = myVegas.Project.Video.Width;
            float dHeightProject = myVegas.Project.Video.Height;
            double dPixelAspect = myVegas.Project.Video.PixelAspectRatio;
            double dAspect = dPixelAspect * dWidthProject / dHeightProject;

            MediaStream mediaStream = GetActiveMediaStream(trackEvent);
            if (!(mediaStream == null))
            {
                VideoStream videoStream = mediaStream as VideoStream;

                double dMediaPixelAspect = videoStream.PixelAspectRatio;
                VideoEvent videoEvent = trackEvent as VideoEvent;
                VideoMotionKeyframes keyframes = videoEvent.VideoMotion.Keyframes; ;

                int cKeyframes = keyframes.Count;

                for (int jj = cKeyframes - 1; jj >= 0; jj--)
                {
                    VideoMotionKeyframe thisKeyframe = keyframes[jj] as VideoMotionKeyframe;
                    MatchOutputAspect(thisKeyframe, dMediaPixelAspect, dAspect);
                }
            }
            myVegas.UpdateUI();
        }

        public MediaStream GetActiveMediaStream(TrackEvent trackEvent)
        {
            try
            {
                if (!(trackEvent.ActiveTake.IsValid()))
                {
                    throw new ArgumentException("empty or invalid take");
                }

                Media media = myVegas.Project.MediaPool.Find(trackEvent.ActiveTake.MediaPath);
                if (null == media)
                {
                    MessageBox.Show("missing media");
                    throw new ArgumentException("missing media");
                }

                MediaStream mediaStream = media.Streams.GetItemByMediaType(MediaType.Video, trackEvent.ActiveTake.StreamIndex);
                return mediaStream;
            }
            catch (Exception e)
            {
                MessageBox.Show("{0}", e.Message);
                return null;
            }
        }


        public void MatchOutputAspect(VideoMotionKeyframe keyframe, double dMediaPixelAspect, double dAspectOut)
        {
            VideoMotionKeyframe keyframeSave = keyframe;

            try
            {
                double rotation = keyframe.Rotation;
                keyframe.RotateBy(-rotation);

                float dWidth = Math.Abs(keyframe.TopRight.X - keyframe.TopLeft.X);
                float dHeight = Math.Abs(keyframe.BottomLeft.Y - keyframe.TopLeft.Y);
                double dCurrentAspect = dMediaPixelAspect * dWidth / dHeight;
                float centerY = keyframe.Center.Y;
                float centerX = keyframe.Center.X;
                double dFactor;

                VideoMotionBounds bounds = new VideoMotionBounds(keyframe.TopLeft, keyframe.TopRight, keyframe.BottomRight, keyframe.BottomLeft);
                if (dCurrentAspect < dAspectOut)
                {
                    // alter y coords            
                    dFactor = dCurrentAspect / dAspectOut;

                    bounds.TopLeft.Y = (bounds.TopLeft.Y - centerY) * (float)dFactor + centerY;
                    bounds.TopRight.Y = (bounds.TopRight.Y - centerY) * (float)dFactor + centerY;
                    bounds.BottomLeft.Y = (bounds.BottomLeft.Y - centerY) * (float)dFactor + centerY;
                    bounds.BottomRight.Y = (bounds.BottomRight.Y - centerY) * (float)dFactor + centerY;
                }
                else
                {
                    // alter x coords
                    dFactor = dAspectOut / dCurrentAspect;

                    bounds.TopLeft.X = (bounds.TopLeft.X - centerX) * (float)dFactor + centerX;
                    bounds.TopRight.X = (bounds.TopRight.X - centerX) * (float)dFactor + centerX;
                    bounds.BottomLeft.X = (bounds.BottomLeft.X - centerX) * (float)dFactor + centerX;
                    bounds.BottomRight.X = (bounds.BottomRight.X - centerX) * (float)dFactor + centerX;
                }

                // set it to new bounds
                keyframe.Bounds = bounds;

                // restore rotation.        
                keyframe.RotateBy(rotation);
            }
            catch
            {
                // restore original settings on error
                keyframe = keyframeSave;
            }
        }

        public void ScaleKeyframe(VideoMotionKeyframe keyframe, float szChange, float rotAngle)
        {
            float cWidth = (1 / (szChange / 100));
            float cHeight = (1 / (szChange / 100));

            if (szChange > 100)
            {
                cWidth = (szChange / 100);
                cHeight = (szChange / 100);
            }

            VideoMotionVertex bounds = new VideoMotionVertex(cWidth, cHeight);

            keyframe.ScaleBy(bounds);
            keyframe.RotateBy((rotAngle * (Math.PI / 180)));
        }

    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

Last changed by Gid on 7/9/2024, 2:11 AM, changed a total of 2 times.

Vegas Pro 22
Vegas Pro/Post 19
Boris Continuum & Sapphire, 
Silhouette Standalone + Plugin, 
Mocha Pro Standalone + Plugin, 
Boris Optics,
NewBlue TotalFX
Desktop PC Microsoft Windows 10 Pro - 64-Bit
ASUS PRO WS WRX80E-SAGE SE WIFI AMD Motherboard
AMD Ryzen Threadripper PRO 3975WX 3.5GHz 32 Core
Corsair iCUE H150i RGB PRO XT 360mm All-in-One Liquid CPU Cooler
RAM 256GB ( 8x Micron 32GB (1x 32GB) 2666MHz DDR4 RAM )
2x Western Digital Black SN850 2TB M.2-2280 SSD, 7000MB/s Read, 5100MB/s Write
(programs on one, project files on the other)
Graphics MSI GeForce RTX 3090 SUPRIM X 24GB OC GPU
ASUS ROG Thor 1200W Semi-Modular 80+ Platinum PSU 
Fractal Design Define 7 XL Dark TG Case with 3 Fans
Dell SE3223Q 31.5 Inch 4K UHD (3840x2160) Monitor, 60Hz, & an Acer 24" monitor.

At the moment my filming is done with a Samsung Galaxy S23 Ultra 5G & a GoPro11

I've been a Joiner/Carpenter for 40yrs, apprentice trained time served, I don't have an apprentice of my own so to share my knowledge I put videos on YouTube.

YouTube videos - https://www.youtube.com/c/Gidjoiner

Lots of work photos on Facebook - https://www.facebook.com/gid.joiner/photos_albums

iEmby wrote on 7/17/2024, 3:08 AM

SCRIPT : Remove Audio from Selected Video Events

using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public void Main(Vegas vegas)
        {
            foreach (Track myTrack in vegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            foreach (TrackEvent ev in evnt.Group)
                            {
                                if (ev != evnt && ev.ActiveTake.Media == evnt.ActiveTake.Media && ev.MediaType == MediaType.Audio)
                                {
                                    ev.Track.Events.Remove(ev);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    //public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

Or you can download from here with png icon file.

https://drive.google.com/drive/folders/1ORPZoqgbujBKsFoPRkjBjYtcKUspk2xB?usp=sharing

Thanks to @zzzzzz9125 for sharing this.

Last changed by iEmby on 7/17/2024, 3:15 AM, changed a total of 3 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/21/2024, 10:26 PM

PSD Layers Splitter Script by @zzzzzz9125

using System;
using System.Windows.Forms;

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;
            myVegas.ResumePlaybackOnScriptExit = true;
            Project project = myVegas.Project;
            Tracks myTracks = project.Tracks;
            bool ctrlMode = ((Control.ModifierKeys & Keys.Control) != 0) ? true : false;

            for (int jj = myTracks.Count - 1; jj >= 0; jj--)
            {
                if (myTracks[jj].IsVideo())
                {
                    foreach (VideoEvent vEvent in myTracks[jj].Events)
                    {
                        VideoTrack myTrack = (VideoTrack) myTracks[jj];
                        if (vEvent.Selected)
                        {
                            if (vEvent.ActiveTake == null || vEvent.ActiveTake.Media == null || vEvent.ActiveTake.MediaStream == null)
                            {
                                continue;
                            }

                            int vStreamCount = vEvent.ActiveTake.Media.StreamCount(MediaType.Video);
                            if (vStreamCount < 2)
                            {
                                continue;
                            }

                            // If you hold down Ctrl and click the script icon on the toolbar, the selected event will be converted to Stream 1 (in a programming sense, it's a video stream with Index 0).
                            if (ctrlMode)
                            {
                                Take newTake = Take.CreateInstance(project, vEvent.ActiveTake.Media.GetVideoStreamByIndex(0));
                                vEvent.Takes.Clear();
                                vEvent.Takes.Add(newTake);
                            }

                            int vStreamIndex = GetVideoStreamIndex(vEvent);
                            if (vStreamIndex == 0)
                            {
                                vEvent.Mute = true;
                            }

                            int vStreamCountAdd = Mod(vStreamIndex - 1, vStreamCount);

                            TrackEventGroup grp = vEvent.Group;
                            if (grp == null)
                            {
                                grp = new TrackEventGroup(project);
                                project.Groups.Add(grp);
                                grp.Add(vEvent);
                            }

                            for (int i = 0; i < vStreamCountAdd; i++)
                            {
                                int j = i + jj;
                                VideoTrack newTrack = null;
                                if (j < myTracks.Count - 1)
                                {
                                    Track trackBelow = myTracks[j + 1];
                                    if (trackBelow.IsVideo() && !((VideoTrack)trackBelow).IsCompositingParent && (vStreamIndex == 0 ? ((VideoTrack)trackBelow).CompositeNestingLevel == myTrack.CompositeNestingLevel + 1 : ((VideoTrack)trackBelow).CompositeNestingLevel == myTrack.CompositeNestingLevel))
                                    {
                                        newTrack = (VideoTrack)trackBelow;
                                    }
                                }

                                if (newTrack == null)
                                {
                                    newTrack = new VideoTrack(project, j + 1, null);
                                    myTracks.Add(newTrack);
                                    newTrack.CompositeNestingLevel = myTrack.CompositeNestingLevel;
                                    if (vStreamIndex == 0)
                                    {
                                        newTrack.CompositeNestingLevel += 1;
                                    }
                                }

                                foreach (VideoEvent evnt in newTrack.Events)
                                {
                                    if (evnt.Start == vEvent.Start)
                                    {
                                        if (evnt.ActiveTake == null || evnt.ActiveTake.Media == null || evnt.ActiveTake.MediaStream == null || evnt.ActiveTake.Media == vEvent.ActiveTake.Media)
                                        {
                                            newTrack.Events.Remove(evnt);
                                        }
                                    }
                                }

                                VideoEvent newEvent = (VideoEvent) vEvent.Copy(newTrack, vEvent.Start);
                                Take newTake = Take.CreateInstance(project, vEvent.ActiveTake.Media.GetVideoStreamByIndex(vStreamCountAdd - i));
                                newEvent.Takes.Clear();
                                newEvent.Takes.Add(newTake);
                                newEvent.Selected = false;
                                newEvent.Mute = false;
                                grp.Add(newEvent);
                            }
                        }
                    }
                }
            }
        }

        public static int Mod(double a, double b)
        {
            int c = (int)(a - Math.Floor(a / b) * b);
            return c;
        }

        public static int GetVideoStreamIndex(VideoEvent vEvent)
        {
            int i = -1;
            foreach (MediaStream ms in vEvent.ActiveTake.Media.Streams)
            {
                if (ms.MediaType == MediaType.Video)
                {
                    i++;
                    if (ms == vEvent.ActiveTake.MediaStream)
                    {
                        return i;
                    }
                }
            }
            return 0;
        }
    }
}


public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Test_Script.Class test = new Test_Script.Class();
        test.Main(vegas);
    }
}

Icon

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/24/2024, 12:24 AM

Import latest downloaded media and placed on timeline at cursor position. (No need to explore Computer) Script will show 5 folders you can choose where you download new media.

ICON FILE:

SCRIPT CODE:

 

using System;
using System.IO;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    private MediaBin downloadBin;
    private string selectedFolder;

    public void FromVegas(Vegas vegas)
    {
        // Show the folder selection form
        FolderSelectionForm form = new FolderSelectionForm();
        DialogResult result = form.ShowDialog();

        if (result == DialogResult.OK)
        {
            selectedFolder = form.SelectedFolder;
        }
        else
        {
            return;
        }

        // Get the latest media file from the selected folder
        FileInfo latestFile = GetLatestMediaFile(selectedFolder, vegas);

        if (latestFile == null)
        {
            MessageBox.Show("No media files found in the selected folder.");
            return;
        }

        // Import the latest file into the project
        Media media = new Media(latestFile.FullName);

        // Create or get the Internet Downloads bin
        downloadBin = AddDownloadBin(vegas);
        downloadBin.Add(media);

        // Determine the type of media and create the appropriate track
        Track track = null;
        if (media.HasVideo())
        {
            track = GetOrCreateTrack(vegas, "Download Media (V)", true);
            Timecode cursorPosition = vegas.Transport.CursorPosition;
            VideoEvent videoEvent = ((VideoTrack)track).AddVideoEvent(cursorPosition, media.Length);
            Take take = videoEvent.AddTake(media.GetVideoStreamByIndex(0));
        }
        else if (media.HasAudio())
        {
            track = GetOrCreateTrack(vegas, "Download Media (A)", false);
            Timecode cursorPosition = vegas.Transport.CursorPosition;
            AudioEvent audioEvent = ((AudioTrack)track).AddAudioEvent(cursorPosition, media.Length);
            Take take = audioEvent.AddTake(media.GetAudioStreamByIndex(0));
        }
    }

    private FileInfo GetLatestMediaFile(string folderPath, Vegas vegas)
    {
        DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
        FileInfo[] mediaFiles = directoryInfo.GetFiles();
        FileInfo latestFile = null;
        DateTime latestTime = DateTime.MinValue;

        foreach (FileInfo file in mediaFiles)
        {
            if (IsMediaFile(file))
            {
                if (!IsFileInMediaPool(file.FullName, vegas) && file.LastWriteTime > latestTime)
                {
                    latestTime = file.LastWriteTime;
                    latestFile = file;
                }
            }
        }

        return latestFile;
    }

    private bool IsMediaFile(FileInfo file)
    {
        string[] validExtensions = { ".mp4", ".mov", ".avi", ".mp3", ".wav", ".jpg", ".png", ".jpeg" };
        foreach (string extension in validExtensions)
        {
            if (file.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }
        }
        return false;
    }

    private bool IsFileInMediaPool(string filePath, Vegas vegas)
    {
        foreach (Media media in vegas.Project.MediaPool)
        {
            if (media.FilePath.Equals(filePath, StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }
        }
        return false;
    }

    private MediaBin AddDownloadBin(Vegas vegas)
    {
        foreach (IMediaBinNode node in vegas.Project.MediaPool.RootMediaBin)
        {
            if (node.NodeType == MediaBinNodeType.Bin)
            {
                MediaBin bin = (MediaBin)node;
                if (bin.Name == "Internet Downloads")
                {
                    downloadBin = bin;
                    return downloadBin;
                }
            }
        }

        downloadBin = new MediaBin(vegas.Project, "Internet Downloads");
        vegas.Project.MediaPool.RootMediaBin.Add(downloadBin);

        return downloadBin;
    }

    private Track GetOrCreateTrack(Vegas vegas, string trackName, bool isVideoTrack)
    {
        foreach (Track t in vegas.Project.Tracks)
        {
            if (t.Name == trackName)
            {
                return t;
            }
        }

        Track track = isVideoTrack ? (Track)new VideoTrack() : new AudioTrack();
        vegas.Project.Tracks.Add(track);
        track.Name = trackName;

        return track;
    }
}

public class FolderSelectionForm : Form
{
    private Button btnDownloads;
    private Button btnPictures;
    private Button btnMusic;
    private Button btnVideos;
    private Button btnScreenShot;
    public string SelectedFolder { get; private set; }

    public FolderSelectionForm()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        btnDownloads = new Button { Text = "Downloads", Left = 10, Top = 10, Width = 200 };
        btnPictures = new Button { Text = "Pictures", Left = 10, Top = 40, Width = 200 };
        btnMusic = new Button { Text = "Music", Left = 10, Top = 70, Width = 200 };
        btnVideos = new Button { Text = "Videos", Left = 10, Top = 100, Width = 200 };
        btnScreenShot = new Button { Text = "ScreenShots", Left = 10, Top = 130, Width = 200 };

        btnDownloads.Click += (sender, e) => { SelectFolder(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Downloads"); };
        btnPictures.Click += (sender, e) => { SelectFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)); };
        btnMusic.Click += (sender, e) => { SelectFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)); };
        btnVideos.Click += (sender, e) => { SelectFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)); };
        btnScreenShot.Click += (sender, e) => { SelectFolder(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\Screenshots"); };

        Controls.Add(btnDownloads);
        Controls.Add(btnPictures);
        Controls.Add(btnMusic);
        Controls.Add(btnVideos);
        Controls.Add(btnScreenShot);

        StartPosition = FormStartPosition.CenterScreen;
        Text = "From ??";
        Size = new System.Drawing.Size(240, 200);
    }

    private void SelectFolder(string folderPath)
    {
        SelectedFolder = folderPath;
        DialogResult = DialogResult.OK;
        Close();
    }
}

 

Last changed by iEmby on 7/24/2024, 12:32 AM, changed a total of 2 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/24/2024, 12:30 AM

Save Your 'Untitled' Project in the name of directory from where most of imported media is in the media pool. (No need to Ctrl + S and write the same name).

Because most of time we name out project at the name of directory.

ICON FILE:

SCRIPT CODE:

using System;
using System.IO;
using System.Collections.Generic;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        Project project = vegas.Project;

        // Check if the project has been saved
        if (string.IsNullOrEmpty(project.FilePath))
        {
            // Project has not been saved
            string savePath = GetSavePathFromMedia(project);

            if (savePath == null)
            {
                // Save the project on the Desktop in "Temporary Projects" directory
                string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string tempProjectsDir = Path.Combine(desktopPath, "Temporary Projects");
                Directory.CreateDirectory(tempProjectsDir);

                savePath = GetUniqueFilePath(tempProjectsDir, "Temporary Project", ".veg");
            }
            else
            {
                // Ensure the file path is unique by appending a counter if needed
                savePath = GetUniqueFilePathFromBase(savePath);
            }

            // Save the project
            vegas.SaveProject(savePath);
        }
    }

    private string GetSavePathFromMedia(Project project)
    {
        string[] validExtensions = {
            ".mp4", ".mov", ".avi", ".mkv", ".wmv", ".flv", ".mpeg", ".mpg",
            ".jpg", ".jpeg", ".png", ".bmp", ".gif", ".veg", ".psd"
        };

        Dictionary<string, int> directoryCount = new Dictionary<string, int>();

        foreach (Media media in project.MediaPool)
        {
            string mediaFilePath = media.FilePath;

            if (!string.IsNullOrEmpty(mediaFilePath))
            {
                string extension = Path.GetExtension(mediaFilePath).ToLower();

                // Check if the file extension is in the valid extensions array
                if (Array.Exists(validExtensions, ext => ext.Equals(extension)))
                {
                    string mediaDirectoryName = Path.GetDirectoryName(mediaFilePath);

                    if (directoryCount.ContainsKey(mediaDirectoryName))
                    {
                        directoryCount[mediaDirectoryName]++;
                    }
                    else
                    {
                        directoryCount[mediaDirectoryName] = 1;
                    }
                }
            }
        }

        if (directoryCount.Count == 0)
        {
            return null;
        }

        // Get the directory with the maximum media files
        string maxMediaDirectory = null;
        int maxCount = 0;
        foreach (var entry in directoryCount)
        {
            if (entry.Value > maxCount)
            {
                maxCount = entry.Value;
                maxMediaDirectory = entry.Key;
            }
        }

        string projectDirectoryName = Path.GetFileName(maxMediaDirectory);
        return Path.Combine(maxMediaDirectory, projectDirectoryName + ".veg");
    }

    private string GetUniqueFilePath(string directory, string baseFileName, string extension)
    {
        int counter = 1;
        string filePath;

        do
        {
            filePath = Path.Combine(directory, baseFileName + "_" + counter + extension);
            counter++;
        } while (File.Exists(filePath));

        return filePath;
    }

    private string GetUniqueFilePathFromBase(string baseFilePath)
    {
        int counter = 1;
        string directory = Path.GetDirectoryName(baseFilePath);
        string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(baseFilePath);
        string extension = Path.GetExtension(baseFilePath);
        string filePath;

        do
        {
            filePath = Path.Combine(directory, fileNameWithoutExtension + "_" + counter + extension);
            counter++;
        } while (File.Exists(filePath));

        return filePath;
    }
}

 

Last changed by iEmby on 7/24/2024, 12:32 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/24/2024, 12:51 AM

Replace Media Everywhere based on Selected Event in VEGAS Pro.

(No need to go to media related to that event in media pool):

by @jetdv

 

ICON FILE:

SCRIPT CODE:

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        foreach (Track track in vegas.Project.Tracks)
        {
            foreach (TrackEvent evnt in track.Events)
            {
                if (evnt.Selected)
                {
                    string basePath = "D:\\Blogs\\";
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.InitialDirectory = basePath;
                    ofd.Filter = "Media Files (*.jpg; *.jpeg; *.bmp; *.mp4; *.mp3; *.mov; *.wav)|*.jpg; *.jpeg; *.bmp; *.mp4; *.mp3; *.mov; *.wav|All Files (*.*)|*.*";
                    ofd.Multiselect = false;
                    ofd.Title = "Select the media file to replace the media of the selected event:";
                    DialogResult dr = ofd.ShowDialog();
                    if (dr != DialogResult.OK)
                    {
                        MessageBox.Show("No file was selected");
                        return;
                    }

                    string file = ofd.FileName;
                    Media media = evnt.ActiveTake.Media;
                    Media newMedia = new Media(file);
                    if (newMedia.IsValid())
                    {
                        media.ReplaceWith(newMedia);
                        return;
                    }
                }
            }
        }
        MessageBox.Show("No events were selected");
    }
}

Check out the tutorial for the scripting method.

Last changed by iEmby on 7/24/2024, 12:52 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/24/2024, 1:07 AM

Convert WEBP to JPEG Script WITH ONE CLICK

For success of this script you have to install

ImageMagick-7.1.1-Q16

DOWNLOAD FROM HERE

 

ICON FILE:

SCRIPT CODE:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms; // For MessageBox
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        try
        {
            // Retrieve the selected events
            List<TrackEvent> selectedEvents = GetSelectedEvents(vegas);
            if (selectedEvents == null || selectedEvents.Count == 0)
            {
                MessageBox.Show("No Event Selected.", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Create a list to store unique media objects
            List<Media> selectedMediaList = new List<Media>();

            // Iterate over the selected events and add their media to the list
            foreach (TrackEvent ev in selectedEvents)
            {
                Media media = ev.ActiveTake.Media;
                if (media != null && !selectedMediaList.Contains(media))
                {
                    selectedMediaList.Add(media);
                }
            }

            // Path to the ImageMagick magick tool
            string magickPath = @"C:\Program Files\ImageMagick-7.1.1-Q16\magick.exe"; // Update with your ImageMagick path

            // Verify the ImageMagick path
            if (!File.Exists(magickPath))
            {
                MessageBox.Show("ImageMagick tool not found at: " + magickPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Process each media file
            foreach (Media media in selectedMediaList)
            {
                // Get the file path of the selected media
                string webpFile = media.FilePath;

                if (string.IsNullOrEmpty(webpFile) || !File.Exists(webpFile))
                {
                    MessageBox.Show("The selected media file is not valid or does not exist: " + webpFile, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                // Skip files that are already in JPEG or PNG format
                string extension = Path.GetExtension(webpFile).ToLower();
                if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".mp4" || extension == ".mov" || extension == ".m2ts")
                {
                    continue;
                }

                // Define the output JPEG file path
                string mediaDirectory = Path.GetDirectoryName(webpFile);
                string outputFileName = Path.GetFileNameWithoutExtension(webpFile) + "_Converted.jpeg";
                string outputFilePathForMedia = Path.Combine(mediaDirectory, outputFileName);

                // Build the command to convert WEBP to JPEG
                string arguments = "convert \"" + webpFile + "\" \"" + outputFilePathForMedia + "\"";

                // Log the command being executed
                Console.WriteLine("Executing command: " + magickPath + " " + arguments);

                // Start the conversion process
                ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    FileName = magickPath,
                    Arguments = arguments,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    UseShellExecute = false,
                    CreateNoWindow = true
                };

                using (Process process = Process.Start(startInfo))
                {
                    string output = process.StandardOutput.ReadToEnd();
                    string error = process.StandardError.ReadToEnd();
                    process.WaitForExit();

                    if (process.ExitCode != 0)
                    {
                        MessageBox.Show("Conversion failed for file: " + webpFile + "\nError: " + error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        continue;
                    }
                }

                // Verify the conversion output
                if (!File.Exists(outputFilePathForMedia))
                {
                    MessageBox.Show("Conversion failed. Output file not found: " + outputFilePathForMedia, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    continue;
                }

                // Delete the original WEBP file
                File.Delete(webpFile);

                // Replace or remove the event based on user's choice
                bool replaceMedia = true; // Set this based on user choice

                if (replaceMedia)
                {
                    Media newMedia = new Media(outputFilePathForMedia); // Create new Media object for the transcoded file

                    // Replace the original media in all events that use this media
                    foreach (TrackEvent selectedEvent in selectedEvents)
                    {
                        if (selectedEvent.ActiveTake.Media == media)
                        {
                            selectedEvent.ActiveTake.Media.ReplaceWith(newMedia);
                        }
                    }
                }

                // Notify the user for each file
                MessageBox.Show("The file [" + Path.GetFileName(webpFile) + "] has been [converted] to JPEG and [replaced].", "Conversion Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        catch (Exception ex)
        {
            // Handle any errors that occur during processing
            MessageBox.Show("An error occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

    private List<TrackEvent> GetSelectedEvents(Vegas vegas)
    {
        List<TrackEvent> selectedEvents = new List<TrackEvent>();

        foreach (Track track in vegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected)
                {
                    selectedEvents.Add(trackEvent);
                }
            }
        }

        return selectedEvents;
    }
}

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 7/24/2024, 1:12 AM

Re-sync Partial Event with Larger Matching Event in VEGAS Pro

by @jetdv

ICON FILE:

SCRIPT CODE:

using System;
using ScriptPortal.Vegas;

public class EntryPoint
{
        public void FromVegas(Vegas vegas)
        {
            TrackEvent FirstEvent = null;
            TrackEvent SecondEvent = null;

            foreach (Track myTrack in vegas.Project.Tracks)
            {
                foreach (TrackEvent evt in myTrack.Events)
                {
                    if (evt.Selected)
                    {
                        if (FirstEvent == null)
                        {
                            FirstEvent = evt;
                        }
                        else
                        {
                            if (SecondEvent == null)
                            {
                                SecondEvent = evt;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }

            if (FirstEvent != null && SecondEvent != null)
            {
                FirstEvent.Start = SecondEvent.Start - SecondEvent.ActiveTake.Offset + FirstEvent.ActiveTake.Offset;
            }
        }
}

Check tutorial related to this.

Last changed by iEmby on 7/24/2024, 1:13 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

zzzzzz9125 wrote on 7/27/2024, 8:46 PM

SCRIPT : Remove Audio from Selected Video Events

using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public void Main(Vegas vegas)
        {
            foreach (Track myTrack in vegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            foreach (TrackEvent ev in evnt.Group)
                            {
                                if (ev != evnt && ev.ActiveTake.Media == evnt.ActiveTake.Media && ev.MediaType == MediaType.Audio)
                                {
                                    ev.Track.Events.Remove(ev);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    //public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

Or you can download from here with png icon file.

https://drive.google.com/drive/folders/1ORPZoqgbujBKsFoPRkjBjYtcKUspk2xB?usp=sharing

Thanks to @zzzzzz9125 for sharing this.

@iEmby A bug was found that when a video event had multiple audio streams, it would delete only half of the audio events. It was caused by the deletion of ev in the foreach loop. Here's the fixed code:

using ScriptPortal.Vegas;
using System.Collections.Generic;

namespace Test_Script
{
    public class Class1
    {
        public void Main(Vegas vegas)
        {
            List<TrackEvent> evs = new List<TrackEvent>();
            foreach (Track myTrack in vegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            foreach (TrackEvent ev in evnt.Group)
                            {
                                if (ev != evnt && ev.ActiveTake.Media == evnt.ActiveTake.Media && ev.MediaType == MediaType.Audio && !evs.Contains(ev))
                                {
                                    evs.Add(ev);
                                }
                            }
                        }
                    }
                }
            }
            foreach (TrackEvent ev in evs)
            {
                ev.Track.Events.Remove(ev);
            }
        }
    }
}

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    //public void FromVegas(Vegas vegas, String scriptFile, XmlDocument scriptSettings, ScriptArgs args)
    {
        Test_Script.Class1 test = new Test_Script.Class1();
        test.Main(vegas);
    }
}

 

Last changed by zzzzzz9125 on 7/27/2024, 8:46 PM, changed a total of 1 times.

Using VEGAS Pro 22 build 194 & VEGAS Pro 21 build 208.

Information about my PC:
Brand Name: HP VICTUS Laptop
System: Windows 11.0 (64-bit) 10.00.22631
CPU: 12th Gen Intel(R) Core(TM) i7-12700H
GPU: NVIDIA GeForce RTX 3050 Laptop GPU
GPU Driver: NVIDIA Studio Driver 560.70

iEmby wrote on 7/28/2024, 6:33 AM

@iEmby A bug was found that when a video event had multiple audio streams, it would delete only half of the audio events. It was caused by the deletion of ev in the foreach loop. Here's the fixed code:

Thanks buddy...

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Jon-Foster wrote on 8/13/2024, 7:17 PM

I can only assume this is on my end since these replies are very recent, but so far every Google Drive link I click on brings up a 404 error. Regardless, thanks in advance!

iEmby wrote on 8/14/2024, 12:45 AM

 

MiniTools by iEmby- Version 1.0

Description Here

DOWNLOAD IT || USE IT || SHARE IT

Old link is not working now.

This is new link

MiniTools by iEmby (Version - 1.0)

Last changed by iEmby on 8/14/2024, 12:46 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 8/18/2024, 2:40 PM

FREEZE / UNFREEZE Frame at cursor

 

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        FreezeLastFrame(vegas);
    }

    private void FreezeLastFrame(Vegas vegas)
    {
        List<TrackEvent> selectedEvents = GetSelectedEvents(vegas);
        if (selectedEvents == null || selectedEvents.Count == 0)
        {
            MessageBox.Show("No Event Selected.", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return;
        }

        Timecode cursorPosition = vegas.Transport.CursorPosition;

        foreach (Track myTrack in vegas.Project.Tracks)
        {
            if (myTrack.IsVideo())
            {
                foreach (VideoEvent vEvent in myTrack.Events)
                {
                    if (vEvent.Selected)
                    {
                        Envelope vEnv = CreateOrResetVelocityEnvelope(vEvent);

                        Timecode relativeCursorPosition = cursorPosition - vEvent.Start;

                        // Check the current velocity value at the cursor position
                        double currentValue = vEnv.ValueAt(relativeCursorPosition);

                        if (currentValue == 1.0)
                        {
                            // Add a freeze point (0.0) at the cursor
                            AddVelocityPoint(vEnv, relativeCursorPosition - Timecode.FromMilliseconds(1), 1.0);
                            AddVelocityPoint(vEnv, relativeCursorPosition, 0.0);
                        }
                        else if (currentValue == 0.0)
                        {
                            // If the last point before the cursor is a freeze point, add a normal point (1.0) at the cursor
                            AddVelocityPoint(vEnv, relativeCursorPosition - Timecode.FromMilliseconds(1), 0.0);
                            AddVelocityPoint(vEnv, relativeCursorPosition, 1.0);
                        }
                    }
                }
            }
        }
    }

    private List<TrackEvent> GetSelectedEvents(Vegas vegas)
    {
        List<TrackEvent> selectedEvents = new List<TrackEvent>();
        foreach (Track track in vegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected)
                {
                    selectedEvents.Add(trackEvent);
                }
            }
        }
        return selectedEvents;
    }

    private Envelope CreateOrResetVelocityEnvelope(VideoEvent vEvent)
    {
        Envelope vEnv = GetVelocityEnvelope(vEvent);

        if (vEnv == null)
        {
            vEnv = new Envelope(EnvelopeType.Velocity);
            vEvent.Envelopes.Add(vEnv);
        }

        return vEnv;
    }

    private Envelope GetVelocityEnvelope(VideoEvent vEvent)
    {
        foreach (Envelope env in vEvent.Envelopes)
        {
            if (env.Type == EnvelopeType.Velocity)
            {
                return env;
            }
        }

        return null;
    }

    private void AddVelocityPoint(Envelope vEnv, Timecode pointLoc, double pointSpeed)
    {
        EnvelopePoint existingPoint = vEnv.Points.GetPointAtX(pointLoc);

        if (existingPoint == null)
        {
            EnvelopePoint newPoint = new EnvelopePoint(pointLoc, pointSpeed);
            vEnv.Points.Add(newPoint);
        }
        else
        {
            existingPoint.Y = pointSpeed;
        }
    }

    private EnvelopePoint GetLastPointBeforeCursor(Envelope vEnv, Timecode cursorPosition)
    {
        EnvelopePoint lastPoint = null;

        foreach (EnvelopePoint point in vEnv.Points)
        {
            if (point.X < cursorPosition)
            {
                lastPoint = point;
            }
            else
            {
                break; // Since points are ordered, we can stop as soon as we pass the cursor position
            }
        }

        return lastPoint;
    }
}

 

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

iEmby wrote on 8/22/2024, 6:20 AM

Merge Tracks | SCRIPT

Compressing project by merging tracks & removing extra tracks by moving events through tracks after considering some conditions.

using System;
using System.Collections.Generic;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        MergeTracks(vegas);
        DeleteEmptyTracks(vegas);
    }

    private void MergeTracks(Vegas vegas)
    {
        // Get all video tracks
        var videoTracks = new List<Track>();
        foreach (var track in vegas.Project.Tracks)
        {
            if (track.IsVideo())
            {
                videoTracks.Add(track);
            }
        }

        // Process tracks from the lowest to the highest
        for (int i = videoTracks.Count - 1; i > 0; i--)
        {
            var currentTrack = videoTracks[i];
            var upperTrack = videoTracks[i - 1];

            // Check if both the current track and the upper track are valid
            if (IsValidTrack(currentTrack) && IsValidTrack(upperTrack))
            {
                // Move events from the current track to the upper track
                MoveEvents(currentTrack, upperTrack);
            }
        }
    }

    private bool IsValidTrack(Track track)
    {
        // Check if the track is a video track and meets all conditions
        if (track.IsVideo())
        {
            var videoTrack = (VideoTrack)track;

            return !HasTrackFX(track) &&
                   !HasEnvelopes(track) &&
                   IsCompositeLevelOne(track) &&
                   IsCompositeModeSrcAlpha(track) &&
                   !IsMuted(track) &&
                   !IsSoloed(track) &&
                   !IsAdjustmentTrack(track) &&
                   !videoTrack.IsCompositingChild && // Ensure track is not a child
                   !videoTrack.IsCompositingParent; // Ensure track is a parent
        }
        return false;
    }

    private void MoveEvents(Track sourceTrack, Track destinationTrack)
    {
        if (sourceTrack.IsVideo() && destinationTrack.IsVideo())
        {
            var sourceVideoTrack = (VideoTrack)sourceTrack;
            var destinationVideoTrack = (VideoTrack)destinationTrack;

            // Iterate over events in the source track
            var eventsToMove = new List<TrackEvent>(sourceVideoTrack.Events);

            foreach (var e in eventsToMove)
            {
                // Check if there's no event directly above this event in the destination track
                bool hasEventAbove = false;
                foreach (var ev in destinationVideoTrack.Events)
                {
                    if (ev.Start < e.Start + e.Length && ev.Start + ev.Length > e.Start)
                    {
                        hasEventAbove = true;
                        break;
                    }
                }

                if (!hasEventAbove)
                {
                    // Copy the event to the destination track at the same start position
                    var copiedEvent = e.Copy(destinationVideoTrack, e.Start);

                    // Remove the event from the source track
                    sourceVideoTrack.Events.Remove(e);
                }
            }
        }
    }

    private bool HasTrackFX(Track track)
    {
        return track.Effects.Count > 0;
    }

    private bool HasEnvelopes(Track track)
    {
        return track.Envelopes.Count > 0;
    }

    private bool IsCompositeLevelOne(Track track)
    {
        if (track.IsVideo())
        {
            var videoTrack = (VideoTrack)track;
            const float levelThreshold = 0.0001f;
            return Math.Abs(videoTrack.CompositeLevel - 1.0f) < levelThreshold;
        }
        return false;
    }

    private bool IsCompositeModeSrcAlpha(Track track)
    {
        if (track.IsVideo())
        {
            var videoTrack = (VideoTrack)track;
            return videoTrack.CompositeMode == CompositeMode.SrcAlpha;
        }
        return false;
    }

    private bool IsMuted(Track track)
    {
        // Check if the track is muted
        return track.Mute;
    }

    private bool IsSoloed(Track track)
    {
        // Check if the track is soloed
        return track.Solo;
    }
    private void DeleteEmptyTracks(Vegas vegas)
    {
        List<Track> tracksToDelete = new List<Track>();
        foreach (Track track in vegas.Project.Tracks)
        {
            // Check if the track is not an adjustment track and has no events
            if (!IsAdjustmentTrack(track) && track.Events.Count == 0)
            {
                // Check if the track is a video track
                if (track.IsVideo())
                {
                    VideoTrack vTrack = (VideoTrack)track;

                    // Check if the track is a compositing parent or a compositing child
                    if (vTrack.IsCompositingParent || vTrack.IsCompositingChild)
                    {
                        // Skip deletion for compositing parent and child tracks
                        continue;
                    }
                }

                // Check if it's an adjustment track
                if (IsAdjustmentTrack(track))
                {
                    // Skip deletion for adjustment tracks, even if they are empty
                    continue;
                }

                tracksToDelete.Add(track);
            }
        }

        // Delete the tracks from the project
        foreach (Track trackToDelete in tracksToDelete)
        {
            vegas.Project.Tracks.Remove(trackToDelete);
        }

        RemoveEmptyAudioTracks(vegas);
    }

    private bool IsAdjustmentTrack(Track track)
    {
        // Check if the track is a video track and is an adjustment track
        return track.IsVideo() && ((VideoTrack)track).IsAdjustmentTrack;
    }

    private void RemoveEmptyAudioTracks(Vegas vegas)
    {
        List<AudioTrack> emptyAudioTracks = new List<AudioTrack>();

        // Iterate through all tracks
        foreach (Track track in vegas.Project.Tracks)
        {
            if (track.IsAudio() && track.Events.Count == 0)
            {
                emptyAudioTracks.Add((AudioTrack)track);
            }
        }

        // Remove the empty audio tracks
        foreach (AudioTrack audioTrackToRemove in emptyAudioTracks)
        {
            vegas.Project.Tracks.Remove(audioTrackToRemove);
        }
    }
}

 

Last changed by iEmby on 8/22/2024, 6:24 AM, changed a total of 1 times.

PROCESSOR
     

Operating System: Windows 11 Pro 64-bit (Always Updated)
System Manufacturer: ASUS
12th Gen Intel(R) Core(TM) i7-12700 (20 CPUs), ~2.1GHz - 4.90GHz
Memory: 32GB RAM
Page File: 11134MB used, 7934MB Available
DirectX Version: DirectX 12

-----------------------------------------------

MOTHERBOARD

 

ASUS PRIME H610-CS D4
Intel® H610 (LGA 1700)
Ready for 12th Gen Intel® Processors
Micro-ATX Motherboard with DDR4
Realtek 1 Gb Ethernet
PCH Heatsink
PCIe 4.0 | M.2 slot (32Gbps) 
HDMI® | D-Sub | USB 3.2 Gen 1 ports
SATA 6 Gbps | COM header
LPT header | TPM header
Luminous Anti-Moisture Coating
5X Protection III
(Multiple Hardware Safeguards
For all-round protection)

-----------------------------------------------
EXTERNAL GRAPHIC CARD

-----------------------------------------------

INTERNAL GRAPHIC CARD (iGPU)

------------------------------------------------

LED - MONITOR

Monitor Name: Generic PnP Monitor
Monitor Model: HP 22es
Monitor Id: HWP331B
Native Mode: 1920 x 1080(p) (60.000Hz)
Output Type: HDMI

-----------------------------------------------

STORAGE DRIVE

Drive: C:
Free Space: 182.3 GB
Total Space: 253.9 GB
File System: NTFS
Model: WD Blue SN570 1TB (NVMe)

---------------O----------------

My System Info (PDF File).

https://drive.google.com/open?id=1-eoLmuXzshTRH_8RunAYAuNocKpiLoiV&usp=drive_fs

 

Also Check

VEGAS Scripts Collection By Me

GitHub Profile

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Thiago_Sase wrote on 8/22/2024, 6:45 AM

Split with Crossfade | SCRIPT

It does similar what "Multicamera Editing mode does by holding Ctrl+Click"; but now you just have to select any event, video or audio, grouped or not.

It does;
1º - It makes a Split;
2º - It makes a crossfade of 1 second;
3º - It adds curveType Slow in the Audio Event.

It can be useful in a lot of scenarios.

 

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode cursorPosition = myVegas.Transport.CursorPosition;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                foreach (TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected)
                    {
                        if (evnt.Start < cursorPosition && evnt.End > cursorPosition)
                        {
                            Timecode splitPoint = cursorPosition - evnt.Start;
                            TrackEvent newEvent = evnt.Split(splitPoint);

                            // Extend the event before the split by 1 second
                            ExtendEventLength(evnt, 1);

                            // Adjust fade curves for the crossfade
                            AdjustCrossfadeCurves(evnt, newEvent, CurveType.Slow);  // Change CurveType to your desired curve
                        }
                    }
                }
            }
        }

        private void ExtendEventLength(TrackEvent trackEvent, double extendValue)
        {
            trackEvent.Length = trackEvent.Length + Timecode.FromSeconds(extendValue);
        }

        private void AdjustCrossfadeCurves(TrackEvent eventBeforeSplit, TrackEvent eventAfterSplit, CurveType curveType)
        {

            AudioEvent aEventBefore = eventBeforeSplit as AudioEvent;
            AudioEvent aEventAfter = eventAfterSplit as AudioEvent;

            if (aEventBefore != null && aEventAfter != null)
            {
                // Adjust fade-out curve for the event before the split
                aEventBefore.FadeOut.Curve = curveType;

                // Adjust fade-in curve for the event after the split
                aEventAfter.FadeIn.Curve = curveType;
            }

        }
    }

    public class EntryPoint
    {
        public void FromVegas(Vegas vegas)
        {
            Test_Script.Class1 test = new Test_Script.Class1();
            test.Main(vegas);
        }
    }
}

 

Last changed by Thiago_Sase on 8/22/2024, 6:46 AM, changed a total of 1 times.

OS: Windows 10 22H2
CPU: Intel Core I7 12700
MEMORY: 32GB DDR4 3200MHz
GHAPHIC CARD: RTX 3060 8GB
HARD DRIVES: SSD for System and M.2 for Media Files

jetdv wrote on 8/22/2024, 8:35 AM

@Thiago_Sase, in AdjustCrossfadeCurves you are converting the track to an audio track. But in the calling routine, I don't see where you're checking to see if it WAS and audio track before calling this routine. Plus, the curve type can also apply to video tracks as well. It appears, to me, that you could get rid of:

            AudioEvent aEventBefore = eventBeforeSplit as AudioEvent;
            AudioEvent aEventAfter = eventAfterSplit as AudioEvent;

And simply adjust eventBeforeSplit and eventAfterSplit instead.

Thiago_Sase wrote on 8/22/2024, 8:39 AM

@jetdv I'll do that. Thank you.

Thiago_Sase wrote on 8/22/2024, 2:31 PM

Split with Crossfade | SCRIPT

Update 1.1
* Better coding logic and structure by @jetdv.
* Changed Curve Type fade In and Out to Linear.

It does similar what "Multicamera Editing mode does by holding Ctrl+Click", but now you just have to select any event, video or audio, grouped or not.

It does;
1º - It makes a Split;
2º - It makes a crossfade of 1 second;
3º - It adds curveType Linear in the Audio and Video Event.

It can be useful in a lot of scenarios.
 

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

        public void Main(Vegas vegas)
        {
            myVegas = vegas;

            Timecode cursorPosition = myVegas.Transport.CursorPosition;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                foreach (TrackEvent evnt in myTrack.Events)
                {
                    if (evnt.Selected)
                    {
                        if (evnt.Start < cursorPosition && evnt.End > cursorPosition)
                        {
                            Timecode splitPoint = cursorPosition - evnt.Start;
                            TrackEvent newEvent = evnt.Split(splitPoint);

                            
                            ExtendEventLength(evnt, 1);

                            
                            AdjustCrossfadeCurves(evnt, newEvent);
                        }
                    }
                }
            }
        }

        private void ExtendEventLength(TrackEvent trackEvent, double extendValue)
        {
            trackEvent.Length = trackEvent.Length + Timecode.FromSeconds(extendValue);
        }

        private void AdjustCrossfadeCurves(TrackEvent eventBeforeSplit, TrackEvent eventAfterSplit)
        {
            
            eventAfterSplit.FadeIn.Curve = CurveType.Linear;

            
            eventAfterSplit.FadeIn.ReciprocalCurve = CurveType.Linear;
        }
    }

    public class EntryPoint
    {
        public void FromVegas(Vegas vegas)
        {
            Test_Script.Class1 test = new Test_Script.Class1();
            test.Main(vegas);
        }
    }
}

 

Last changed by Thiago_Sase on 8/22/2024, 2:33 PM, changed a total of 4 times.

OS: Windows 10 22H2
CPU: Intel Core I7 12700
MEMORY: 32GB DDR4 3200MHz
GHAPHIC CARD: RTX 3060 8GB
HARD DRIVES: SSD for System and M.2 for Media Files

jetdv wrote on 8/22/2024, 10:54 PM

To be dockable and remain open all the time, it MUST be a "Custom Command"...