how can i add freeze frame at markers via script?

iEmby wrote on 2/8/2024, 6:52 AM

i want to create freeze frame at the one frame before the last frame of selected event.
i create script for adding markers at required position.

i need a code of adding velocity point at markers which should be freeze.New comment

in simple words there will be two velocity points

first ---- at third last frame of value 100%

second --- at second last frame of value 0%

this is script for add markers at second last frame of selected events

 

using System;

using System.Collections.Generic;

using ScriptPortal.Vegas;

using System.Windows.Forms;

 

public class EntryPoint

{

    public void FromVegas(Vegas vegas)

    {

        List<TrackEvent> selectedEvents = GetSelectedEvents(vegas);

 

        if (selectedEvents != null && selectedEvents.Count > 0)

        {

            AddMarkerOneFrameBeforeLastFrame(selectedEvents, vegas);

            MessageBox.Show("Markers added one frame before the last frame of selected events.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        else

        {

            ShowWarningMessage("No selected events in the project.");

        }

    }

 

    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.Count > 0 ? selectedEvents : null;

    }

 

    private void AddMarkerOneFrameBeforeLastFrame(List<TrackEvent> selectedEvents, Vegas vegas)

    {

        foreach (TrackEvent selectedEvent in selectedEvents)

        {

            // Calculate one frame before the last frame time

            Timecode oneFrameBeforeLastFrame = selectedEvent.Start + selectedEvent.Length - Timecode.FromMilliseconds(1);

 

            // Add a marker one frame before the last frame of the selected event

            Marker marker = new Marker(oneFrameBeforeLastFrame);

            vegas.Project.Markers.Add(marker);

 

            // Refresh the Vegas UI

            vegas.UpdateUI();

        }

    }

 

    private void ShowWarningMessage(string message)

    {

        // Use a MessageBox or any other method to display the warning message

        MessageBox.Show(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

    }

}

 

 

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

m3lquixd wrote on 2/8/2024, 7:58 AM

I liked the idea of this script, I don't understand why it needs the marker.
But in this case, it's not working yet, right?

And you can place your code within this section, it becomes more organized. 😀

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 2/8/2024, 9:57 AM

You need to adjust the Velocity Envelope. As was mentioned, you really don't need to add markers. This will let you find the velocity envelope on an event:

This one shows how to read the value of the envelope at any point in the envelope:

First, add this routine to your code:

        public void AddVelocityPoint(Envelope VelEnv, Timecode PointLoc, double PointSpeed)
        {
            EnvelopePoint a = VelEnv.Points.GetPointAtX(PointLoc);
            if (a == null)
            {
                a = new EnvelopePoint(PointLoc, PointSpeed);
                VelEnv.Points.Add(a);
            }
            else
            {
                a.Y = PointSpeed;
            }
        }

Then you can eliminate the creation of the markers and use this for each video event as needed:

                            VideoEvent vevnt = (VideoEvent)evnt;
                            Envelope vEnv = null;
                            foreach (Envelope env in vevnt.Envelopes)
                            {
                                if (env.Type == EnvelopeType.Velocity)
                                {
                                    vEnv = env;
                                }
                            }
                            if (vEnv == null)
                            {
                                vEnv = new Envelope(EnvelopeType.Velocity);
                                vevnt.Envelopes.Add(vEnv);
                            }

                            Timecode oneFrameBeforeLastFrame = selectedEvent.Length - Timecode.FromMilliseconds(1);
                            AddVelocityPoint(vEnv, oneFrameBeforeLastFrame, 1.0);
                            AddVelocityPoint(vEnv, selectedEvent.Length, 0.0);

Naturally, to see the "frozen" image you'll need to lengthen each of those events.

m3lquixd wrote on 2/8/2024, 11:38 AM

@iEmby If you can make it work, please make it available here for everyone, I'm interested in this script!​​​​​​​

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

jetdv wrote on 2/8/2024, 12:00 PM

Try this to add a freeze frame at the end of each selected event. As I noted above, you'll need to now extend the events in order to see the frozen frame. No markers needed...

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;

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach(VideoEvent vEvent in myTrack.Events)
                    {
                        if (vEvent.Selected)
                        {
                            Envelope vEnv = null;
                            foreach (Envelope env in vEvent.Envelopes)
                            {
                                if (env.Type == EnvelopeType.Velocity)
                                {
                                    vEnv = env;
                                }
                            }
                            if (vEnv == null)
                            {
                                vEnv = new Envelope(EnvelopeType.Velocity);
                                vEvent.Envelopes.Add(vEnv);
                            }

                            Timecode oneFrameBeforeLastFrame = vEvent.Length - Timecode.FromMilliseconds(1);
                            AddVelocityPoint(vEnv, oneFrameBeforeLastFrame, 1.0);
                            AddVelocityPoint(vEnv, vEvent.Length, 0.0);
                        }
                    }
                }
            }
        }

        public void AddVelocityPoint(Envelope VelEnv, Timecode PointLoc, double PointSpeed)
        {
            EnvelopePoint a = VelEnv.Points.GetPointAtX(PointLoc);
            if (a == null)
            {
                a = new EnvelopePoint(PointLoc, PointSpeed);
                VelEnv.Points.Add(a);
            }
            else
            {
                a.Y = PointSpeed;
            }
        }
    }
}

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

 

m3lquixd wrote on 2/8/2024, 12:22 PM

Thank you!

About me:
Hi! Melqui Calheiros Here. I've been using Vegas as my only video editor for over 10 years. I edit professionally for various influencers, public bodies and small businesses. My goal is to squeeze Vegas to the fullest! And end the prejudice that software has here in Brazil.

⬇️ Some of my jobs. ⬇️
https://www.vegascreativesoftware.info/us/forum/post-your-vegas-creations--109464/?page=37#ca872169

PC Specs:
Operating System:
    Windows 11 Pro 64-bit
CPU:
    AMD Ryzen 7 5700G 3.80 GHz
RAM:
    32,0GB Dual-Channel DDR4 3200MHz
Motherboard:
    ASRock B450M Steel Legend (AM4)
Graphics:
    MSI RTX 4060 Ventus 2X Black OC 8GB
Storage:
    476GB ADATA SU650 (SATA (SSD))
    931GB KINGSTON SNV2S1000G (SATA-2 (SSD))

iEmby wrote on 2/9/2024, 4:05 AM

@jetdv thanks so much sir.. u r really god to me.💯💯

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)

iEmby wrote on 2/11/2024, 4:11 PM

@jetdv sir how can i get that a track is a parent track or not.. how can i get it via code?
 

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 2/11/2024, 8:29 PM

@iEmby, here's a simple case. But there's a lot more that can be determined. I'll have to create a new tutorial on that.

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    VideoTrack vTrack = (VideoTrack)myTrack;
                    bool IsParent = vTrack.IsCompositingParent;
                }
            }

Also see here:

 

iEmby wrote on 2/12/2024, 3:05 AM

@iEmby, here's a simple case. But there's a lot more that can be determined. I'll have to create a new tutorial on that.

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    VideoTrack vTrack = (VideoTrack)myTrack;
                    bool IsParent = vTrack.IsCompositingParent;
                }
            }

Also see here:

 

thanks for your unconditional support sir

 

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)