Transcode & replace media file while active project opened. Possible?

iEmby wrote on 7/19/2024, 7:18 AM

I want to add a new checkbox in my Quick Render script (shared in Script Collection Thread).

ok what i want from it...

  1. user will select one or multiple events.
  2. and user will check Transcode Media box
  3. it will disable all other checkbox (which i have done)
  4. User will run any render from above list or render other template.
  5. it will ask user about if he/she want to replace media with transcoded or not?
  6. then it will first find media linked with selected event, (or first selected event in case of multiple selected events)
  7. then it will add that media on timeline on a new video and audio track as an new event at 30 second ahead timecode of the ending of project.
  8. then it will create loop region on that.
  9. then it render that loop region it as per selected template. (rendering process is already good as per old workflow of script) with a suffix _transcoded
  10. after render it will replace that media with transcoded media (if user select to replace) otherwise it will remove that event from timeline then continue same process on next selected event (if multiple selected) otherwise show success message.

so is this possible ??

 

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 7/19/2024, 9:02 AM

hurreeeeeyyyyy 😇😇💯💯💯

i did it again with the help of ChatGPT.

check this out

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

            // Ask user if they want to replace the original media with the transcoded media
            DialogResult result = MessageBox.Show("Replace the original media with the transcoded media?", "Replace Media", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            bool replaceMedia = (result == DialogResult.Yes);

            foreach (TrackEvent selectedEvent in selectedEvents)
            {
                Take activeTake = selectedEvent.ActiveTake;
                Media media = activeTake.Media;
                if (media == null)
                {
                    MessageBox.Show("Selected event has no media linked!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    continue;
                }

                // Calculate the new event position
                Timecode newEventStart = vegas.Project.Length + new Timecode(30.0); // 30 seconds ahead of the project end

                // Create new tracks and add media as events
                VideoTrack videoTrack = new VideoTrack(vegas.Project.Tracks.Count, "TranscodeVideoTrack");
                vegas.Project.Tracks.Add(videoTrack);
                AudioTrack audioTrack = new AudioTrack(vegas.Project.Tracks.Count + 1, "TranscodeAudioTrack");
                vegas.Project.Tracks.Add(audioTrack);

                // Add new video and audio events
                TrackEvent newVideoEvent = videoTrack.AddVideoEvent(newEventStart, media.Length);
                TrackEvent newAudioEvent = audioTrack.AddAudioEvent(newEventStart, media.Length);

                // Set media streams for the new events
                MediaStream videoStream = media.GetVideoStreamByIndex(0);
                MediaStream audioStream = media.GetAudioStreamByIndex(0);
                if (videoStream != null)
                {
                    newVideoEvent.AddTake(videoStream);
                }
                if (audioStream != null)
                {
                    newAudioEvent.AddTake(audioStream);
                }

                // Create a loop region around the new event
                vegas.Transport.LoopRegionStart = newEventStart;
                vegas.Transport.LoopRegionLength = media.Length;

                // Define the output file path
                string outputFileName = $"{Path.GetFileNameWithoutExtension(media.FilePath)}_transcoded{fileExtension}";
                string outputFilePath = GetOutputFilePath(outputFileName, overwriteBox.Checked);

                // Setup render arguments
                RenderArgs renderArgs = new RenderArgs
                {
                    OutputFile = outputFilePath,
                    RenderTemplate = renderTemplate,
                    Start = newEventStart,
                    Length = media.Length
                };

                // Render the project
                RenderProject(renderArgs);

                // Replace or remove the event based on user's choice
                if (replaceMedia)
                {

                    // REPLACING CODE ----------------- ??????????


                    // Remove the temporary events and tracks
                    videoTrack.Events.Remove(newVideoEvent);
                    audioTrack.Events.Remove(newAudioEvent);
                    vegas.Project.Tracks.Remove(videoTrack);
                    vegas.Project.Tracks.Remove(audioTrack);
                }
                else
                {
                    // Just remove the temporary events and tracks
                    videoTrack.Events.Remove(newVideoEvent);
                    audioTrack.Events.Remove(newAudioEvent);
                    vegas.Project.Tracks.Remove(videoTrack);
                    vegas.Project.Tracks.Remove(audioTrack);
                }
                vegas.UpdateUI();
            }
        }

but unable to create code for replacing original media with transcoding media

Last changed by iEmby on 7/19/2024, 9:06 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)

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

I guess you haven't watched my last two tutorials?

iEmby wrote on 7/19/2024, 11:56 AM

I guess you haven't watched my last two tutorials?

thankyou sir i got it...

you are genius 😀😀

 

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/19/2024, 11:58 AM

just one minor problem
when i select event (video stream and its audio stream) which are single event.

but when i transcode it count it as two events so it transcode it twice.

can u find what to change?

 

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

            // Ask user if they want to replace the original media with the transcoded media
            DialogResult result = MessageBox.Show("Replace the original media with the transcoded media?", "Replace Media", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            bool replaceMedia = (result == DialogResult.Yes);

            foreach (TrackEvent selectedEvent in selectedEvents)
            {
                Take activeTake = selectedEvent.ActiveTake;
                Media media = activeTake.Media;
                if (media == null)
                {
                    MessageBox.Show("Selected event has no media linked!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    continue;
                }

                // Calculate the new event position
                Timecode newEventStart = vegas.Project.Length + new Timecode(30.0); // 30 seconds ahead of the project end

                // Create new tracks and add media as events
                VideoTrack videoTrack = new VideoTrack(vegas.Project.Tracks.Count, "TranscodeVideoTrack");
                vegas.Project.Tracks.Add(videoTrack);
                AudioTrack audioTrack = new AudioTrack(vegas.Project.Tracks.Count + 1, "TranscodeAudioTrack");
                vegas.Project.Tracks.Add(audioTrack);

                // Add new video and audio events
                TrackEvent newVideoEvent = videoTrack.AddVideoEvent(newEventStart, media.Length);
                TrackEvent newAudioEvent = audioTrack.AddAudioEvent(newEventStart, media.Length);

                // Set media streams for the new events
                MediaStream videoStream = media.GetVideoStreamByIndex(0);
                MediaStream audioStream = media.GetAudioStreamByIndex(0);
                if (videoStream != null)
                {
                    newVideoEvent.AddTake(videoStream);
                }
                if (audioStream != null)
                {
                    newAudioEvent.AddTake(audioStream);
                }

                // Create a loop region around the new event
                vegas.Transport.LoopRegionStart = newEventStart;
                vegas.Transport.LoopRegionLength = media.Length;

                // Define the output file path
                string outputFileName = $"{Path.GetFileNameWithoutExtension(media.FilePath)}_transcoded{fileExtension}";
                string outputFilePath = GetOutputFilePath(outputFileName, overwriteBox.Checked);

                // Setup render arguments
                RenderArgs renderArgs = new RenderArgs
                {
                    OutputFile = outputFilePath,
                    RenderTemplate = renderTemplate,
                    Start = newEventStart,
                    Length = media.Length
                };

                // Render the project
                RenderProject(renderArgs);

                // Replace the media based on user's choice
                if (replaceMedia)
                {
                    Media originalMedia = selectedEvent.ActiveTake.Media;
                    Media newMedia = new Media(outputFilePath); // Create new Media object for the transcoded file

                    originalMedia.ReplaceWith(newMedia);


                    // Remove the temporary events and tracks
                    videoTrack.Events.Remove(newVideoEvent);
                    audioTrack.Events.Remove(newAudioEvent);
                    vegas.Project.Tracks.Remove(videoTrack);
                    vegas.Project.Tracks.Remove(audioTrack);
                }
                else
                {
                    // Just remove the temporary events and tracks
                    videoTrack.Events.Remove(newVideoEvent);
                    audioTrack.Events.Remove(newAudioEvent);
                    vegas.Project.Tracks.Remove(videoTrack);
                    vegas.Project.Tracks.Remove(audioTrack);
                }
                vegas.UpdateUI();
            }
        }

 

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/19/2024, 12:47 PM

look at this video when i select full event (audio + video) it render twice

and when i select once it render once

 

what i think from it.

when it first time trancoded it replace media then it thinks it is another media bcoz of file name changes.

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/19/2024, 8:56 PM

just one minor problem
when i select event (video stream and its audio stream) which are single event.

but when i transcode it count it as two events so it transcode it twice.

can u find what to change?

@iEmby Maybe you should filter out the media you need in advance, such as adding the following code:

using System.Linq;

...

List<Media> selectedMediaList = selectedEvents.ConvertAll<Media>(ev => ev.ActiveTake.Media as Media).Distinct().ToList();

foreach (Media selectedMedia in selectedMediaList)
{
    ...
}

ConvertAll<Media>(ev => ev.ActiveTake.Media as Media) is to convert all selected events to media, and Distinct().ToList() is to remove duplicate media. In the foreach loop, you should also use media instead of events. This way, when you select multiple events from the same media, the media will only be converted once.

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/19/2024, 9:35 PM

just one minor problem
when i select event (video stream and its audio stream) which are single event.

but when i transcode it count it as two events so it transcode it twice.

can u find what to change?

@iEmby Maybe you should filter out the media you need in advance, such as adding the following code:

using System.Linq;

...

List<Media> selectedMediaList = selectedEvents.ConvertAll<Media>(ev => ev.ActiveTake.Media as Media).Distinct().ToList();

foreach (Media selectedMedia in selectedMediaList)
{
    ...
}

ConvertAll<Media>(ev => ev.ActiveTake.Media as Media) is to convert all selected events to media, and Distinct().ToList() is to remove duplicate media. In the foreach loop, you should also use media instead of events. This way, when you select multiple events from the same media, the media will only be converted once.

thanks buddy,.. this workssss.s.

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/19/2024, 9:36 PM
private void TranscodeMedia(RenderTemplate renderTemplate, string fileExtension)
{
    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);
        }
    }

    // Ask user if they want to replace the original media with the transcoded media
    DialogResult result = MessageBox.Show("Replace the original media with the transcoded media?", "Replace Media", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    bool replaceMedia = (result == DialogResult.Yes);

    foreach (Media media in selectedMediaList)
    {
        if (media == null)
        {
            MessageBox.Show("Selected event has no media linked!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            continue;
        }

        // Calculate the new event position
        Timecode newEventStart = vegas.Project.Length + new Timecode(30.0); // 30 seconds ahead of the project end

        // Create new tracks and add media as events
        VideoTrack videoTrack = new VideoTrack(vegas.Project.Tracks.Count, "TranscodeVideoTrack");
        vegas.Project.Tracks.Add(videoTrack);
        AudioTrack audioTrack = new AudioTrack(vegas.Project.Tracks.Count + 1, "TranscodeAudioTrack");
        vegas.Project.Tracks.Add(audioTrack);

        // Add new video and audio events
        TrackEvent newVideoEvent = videoTrack.AddVideoEvent(newEventStart, media.Length);
        TrackEvent newAudioEvent = audioTrack.AddAudioEvent(newEventStart, media.Length);

        // Set media streams for the new events
        MediaStream videoStream = media.GetVideoStreamByIndex(0);
        MediaStream audioStream = media.GetAudioStreamByIndex(0);
        if (videoStream != null)
        {
            newVideoEvent.AddTake(videoStream);
        }
        if (audioStream != null)
        {
            newAudioEvent.AddTake(audioStream);
        }

        // Create a loop region around the new event
        vegas.Transport.LoopRegionStart = newEventStart;
        vegas.Transport.LoopRegionLength = media.Length;

        // Define the output file path
        string outputFileName = $"{Path.GetFileNameWithoutExtension(media.FilePath)}_transcoded{fileExtension}";
        string outputFilePath = GetOutputFilePath(outputFileName, overwriteBox.Checked);

        // Setup render arguments
        RenderArgs renderArgs = new RenderArgs
        {
            OutputFile = outputFilePath,
            RenderTemplate = renderTemplate,
            Start = newEventStart,
            Length = media.Length
        };

        // Render the project
        RenderProject(renderArgs);

        // Replace or remove the event based on user's choice
        if (replaceMedia)
        {
            Media newMedia = new Media(outputFilePath); // 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);
                }
            }

            // Remove the temporary events and tracks
            videoTrack.Events.Remove(newVideoEvent);
            audioTrack.Events.Remove(newAudioEvent);
            vegas.Project.Tracks.Remove(videoTrack);
            vegas.Project.Tracks.Remove(audioTrack);
        }
        else
        {
            // Just remove the temporary events and tracks
            videoTrack.Events.Remove(newVideoEvent);
            audioTrack.Events.Remove(newAudioEvent);
            vegas.Project.Tracks.Remove(videoTrack);
            vegas.Project.Tracks.Remove(audioTrack);
        }
        vegas.UpdateUI();
    }
}

 

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)