This script should remove all selected video event's audio stream but

iEmby wrote on 7/16/2024, 11:30 PM

i created this script for removing selected video events audio streams only selected not all same media video event's

but it is doing wrong. please check above video.

Last changed by iEmby

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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

Comments

iEmby wrote on 7/17/2024, 12:52 AM
using ScriptPortal.Vegas;
using System.Collections.Generic;
using System.Windows.Forms;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        // Check if any video event is selected
        List<TrackEvent> selectedVideoEvents = new List<TrackEvent>();
        foreach (Track track in vegas.Project.Tracks)
        {
            if (track.IsVideo())
            {
                foreach (TrackEvent trackEvent in track.Events)
                {
                    if (trackEvent.Selected)
                    {
                        selectedVideoEvents.Add(trackEvent);
                    }
                }
            }
        }

        if (selectedVideoEvents.Count == 0)
        {
            MessageBox.Show("Please select one or more video events.");
            return;
        }

        // Delete corresponding audio events
        foreach (TrackEvent videoEvent in selectedVideoEvents)
        {
            Media videoMedia = videoEvent.ActiveTake.Media;
            if (videoMedia == null)
            {
                continue; // Skip if video media is null
            }

            foreach (Track track in vegas.Project.Tracks)
            {
                if (track.IsAudio())
                {
                    List<TrackEvent> audioEventsToDelete = new List<TrackEvent>();
                    foreach (TrackEvent audioEvent in track.Events)
                    {
                        foreach (Take audioTake in audioEvent.Takes)
                        {
                            Media audioMedia = audioTake.Media;
                            if (audioMedia != null && audioMedia == videoMedia)
                            {
                                audioEventsToDelete.Add(audioEvent);
                                break; // Found matching audio event, add to delete list
                            }
                        }
                    }

                    // Remove identified audio events
                    foreach (TrackEvent audioEventToDelete in audioEventsToDelete)
                    {
                        track.Events.Remove(audioEventToDelete);
                    }
                }
            }
        }
    }
}

please checkout this script.

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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

zzzzzz9125 wrote on 7/17/2024, 1:07 AM

A simple script:

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);
    }
}

I would advise you to ask yourself this question and not rely too much on ChatGPT.

Using VEGAS Pro 22 build 248 & 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/17/2024, 2:56 AM

I would advise you to ask yourself this question and not rely too much on ChatGPT.

bro i am not a coder actually..

but i think knowing coding is not completely necessary these days, all we can done by AI.

where i stuck, i ask you expert guys.

look at these scripts, i created with help of ChatGPT..

 

Batch Render (Revised)

https://www.vegascreativesoftware.info/us/forum/vegas-pro-scripts-collections-share-your-script-here--145667/#ca913772

Quick Render

https://www.vegascreativesoftware.info/us/forum/vegas-pro-scripts-collections-share-your-script-here--145667/#ca913773

MiniTools (Version-1)

https://www.vegascreativesoftware.info/us/forum/vegas-pro-scripts-collections-share-your-script-here--145667/#ca916979

Every tool in this i created in ChatGPT except some complex code in which @jetdv sir helped me.

 

I just know how to get work from ChatGPT.

otherwise you guys always here to help.

thanks for sharing code

Last changed by iEmby on 7/17/2024, 2:58 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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 7/17/2024, 9:54 AM

bro i am not a coder actually..

but i think knowing coding is not completely necessary these days, all we can done by AI.

@iEmby I agree with @zzzzzz9125 - I can see using ChatGPT for some advice but, based on the code I've seen:

  1. It produces code that is overly complicated for what needs to be done
  2. It, too often, does not provide the correct results

So I would not say it "can all be done by AI". I can say that using ChatGPT to point you in the right direction might be good. But I wouldn't fully trust the code generated there.

iEmby wrote on 7/17/2024, 10:05 AM

yeah you are absolutely right sir,,,

but how can i learn this csharp language just atleast for VEGAS scripting.. i understand code 20-30 % but some time i got confused.

like this first one.

i never understood one thing if we can write a script like

 

using ScriptPortal.Vegas;

namespace EntryPoint
{
    public void FromVegas(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);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

then why you guys start scripts from
 

namespace Test_Script
{
    public class Class1
    {
        public void Main(Vegas vegas)
        {

and end it with

public class EntryPoint
{
    public void FromVegas(Vegas vegas)

both ways are working same.

i never understand the difference between them.

i know i can ask this to chat GPT but i wanna know from u guys.

Last changed by iEmby on 7/17/2024, 10:07 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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 7/17/2024, 11:59 AM

VEGAS requires the "entrypoint" in order to know how to start the script. That's why I end every one of mine with something like:

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

Now, where I have this:

         Test_Script.Class1 test = new Test_Script.Class1();
         test.Main(vegas); 

in the script above, he placed the actual code. I, personally, like to keep that separate which is why I created the extra namespace and called it to keep everything separate. So I have this:

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

        }

    }
}

I can change the "namespace" and "class" names to be whatever is useful for my script. Then I just change the corresponding information on these two lines:

        [namespace].[class] [varName] = new [namespace].[class]();
        [varName].Main(vegas);

Then, instead of in the "entrypoint", I put all of my code in the new class. Everything in the main routine goes under "myVegas = vegas;" and then my subroutines all go in the new class. It just feels "cleaner" to me to keep the "entrypoint" separate.

In fact, the initial routine in the new class doesn't even have to be called "Main". It could also be something different if that makes more sense for the script you're creating.

So, yes, you can do it either way. It's "shorter" to put all the code in the "entrypoint". To me, it's "cleaner" to have the "entrypoint" left simple where it only calls my "class" which has all of my other routines.

You might also look at a "Learning C#" book for the basics of C# not in relation to VEGAS. Specifically for VEGAS, I've tried to make many good tutorials but always welcome suggestions for more. But my tutorials are mainly based on "this is how something can be done" - not necessarily "this is how the specific task I'm looking for can be done." The tutorials assume you'll need modifications to do your specific task.

For example, it shows how to add a generated media to the timeline using Titles and Text. If you need to add a "Solid Color" to the timeline, the process is the same, you just need to choose "Solid Color" instead of Titles and Text so I really don't want a separate tutorial on how to add a "Solid Color". I hope that makes sense.

For the tutorials, generally speaking I've just found that it makes more sense to start with this:
 

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;

            PLACE ALL OF MY NEW CODE HERE
        }

        ANY SUBROUTINES WOULD GO HERE

    }
}

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

Even if it is a little longer than needed and specifies "Using" lines that are not being used in this specific script (they could be trimmed out later if desired but really don't hurt anything.)

iEmby wrote on 7/18/2024, 12:01 AM

SIR....

Thankyou so much for this explanation..

this is very understandable now....

in my simple understanding.

ENTRYPOINT & FROM VEGAS are the entry gates to VEGAS.

so even after creating manual namespaces, classes and methods.

we have to insert it into

ENTRYPOINT & FROM VEGAS are the entry gates to VEGAS.

these.. so that out VEGAS can understood.

i hope i am right.

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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 7/18/2024, 9:02 AM

Yes, "Entrypoint" and "FromVegas" are required so that VEGAS knows how to start the script. Without those, the script will not run using C#.

Now older JScript scripts did not have that requirement. For example, save this as "version.js" and it will run fine:

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

MessageBox.Show(Vegas.Version);

The C# equivalent "version.cs" is:

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

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        MessageBox.Show(vegas.Version);
    }
}

 

iEmby wrote on 7/19/2024, 4:04 AM

yes sir,, i understood..

i started now C# course from Microsoft Learn....

i am getting so many points from that.. i am learning fast because some of it i learn while creating scripts, finding mistakes, finding error via help of ChatGPT...

but i think the more challenging part it..

understanding VEGAS Scripting API...

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

Some useful creations by me including VEGAS Scripts

https://getopensofts.blogspot.com/

 

My YouTube Channel Dedicated to Only VEGAS Pro Tutorials

EDITROOM : My YouTube Channel (For VEGAS Tutorials)

jetdv wrote on 7/19/2024, 10:38 AM

but i think the more challenging part it..

understanding VEGAS Scripting API...

That's why I've made a bunch of tutorials!!!