Create a script that lauch video stabilization plugin?

Thiago_Sase wrote on 7/5/2024, 10:34 AM

Hello guys,

Please, is it possible for someone help me to create a script that lauchs Video Stabilization plugin with user view option = Expert ??

Comments

jetdv wrote on 7/5/2024, 10:58 AM

Can you please better explain what you're requesting?

Also, there's several stabilizers. Which one are you referring to?

Thiago_Sase wrote on 7/5/2024, 11:22 AM

Thank you for answering.

I meant, a script that lauchs Vegas Video Stabilization OFX plugin.

The plugin has a option - user viewer - and it has 3 options: Basic, Professional and Expert.

I'd like to apply the plugin, Vegas Video Stabilization OFX, with the option - user view: expert - selected, via script.

Is it possible to do that? Thanks.

jetdv wrote on 7/5/2024, 11:50 AM

@Thiago_Sase like 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;

            foreach(Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach(VideoEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            string plugInUID = "{Svfx:de.magix:Stabilize}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            evnt.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;
                            OFXChoiceParameter X = (OFXChoiceParameter)ofx["Views"];
                            X.Value = X.Choices[2];
                            X.ParameterChanged();

                            evnt.OpenVideoEffectUI();
                        }
                    }
                }
            }
        }
      

    }
}

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

 

Thiago_Sase wrote on 7/5/2024, 11:58 AM

It Worked perfectly. Thank you very much sir! You are a legend!

Thiago_Sase wrote on 7/16/2024, 6:08 PM

@jetdv Hello Sir,

Please, is it possible to add in the code the Analyze Motion push button and analyze automatically?

 

jetdv wrote on 7/16/2024, 6:35 PM

@Thiago_Sase, Give this a try...

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 evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            string plugInUID = "{Svfx:de.magix:Stabilize}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            evnt.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;
                            OFXChoiceParameter X = (OFXChoiceParameter)ofx["Views"];
                            X.Value = X.Choices[2];
                            X.ParameterChanged();

                            evnt.OpenVideoEffectUI();

                            foreach (OFXParameter parm in ofx.Parameters)
                            {
                                if (parm.ParameterType.ToString() == "PushButton" && parm.Name == "AnalyzeMotion")
                                {
                                    parm.ParameterChanged();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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

 

Thiago_Sase wrote on 7/16/2024, 6:50 PM

@jetdv It worked! Thank you very much.

I was watching your video tutorial on youtube about "Push Button" and this line of the code was a game changer for me;

" && parm.Name == "AnalyzeMotion "

It worked like magic.

Thank you Sir!

Thiago_Sase wrote on 7/16/2024, 8:15 PM

@jetdv Sir, one last question;

Please, If i want to add in this script bellow the Preset "Black" from media generator solid color and add an videoFX effect plugin Brightness and contrast?

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


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

            //Add Media Generate Solid Color to the first track

            Track mytrack = myVegas.Project.Tracks[0];
            

            string genUID = "{Svfx:com.vegascreativesoftware:solidcolor}";
        
            PlugInNode plugIn = null;
            plugIn = myVegas.Generators.GetChildByUniqueID(genUID);

            
            Media media = new Media(plugIn);
            MediaStream stream = media.Streams.GetItemByMediaType(MediaType.Video, 0);
            VideoEvent newEvent = new VideoEvent(myVegas.Transport.CursorPosition, Timecode.FromSeconds(15));
            mytrack.Events.Add(newEvent);
            Take take = new Take(stream);
            newEvent.Takes.Add(take);

         


        }

    }
}


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 7/16/2024, 8:19 PM, 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 7/17/2024, 9:59 AM

@Thiago_Sase

How to get the list of effects:

How to add an effect and pick a preset:

Add Generated Media to the timeline:

Pick the preset of the Generated Media the same as you would an effect.

Steve_Rhoden wrote on 7/17/2024, 6:05 PM

Was just wondering if this script can be modified to do the exact same thing with Prodad Mercalli V5 instead.

Thiago_Sase wrote on 7/17/2024, 6:45 PM

@Thiago_Sase

How to get the list of effects:

How to add an effect and pick a preset:

Add Generated Media to the timeline:

Pick the preset of the Generated Media the same as you would an effect.


@jetdv 

I watched the tutorial videos and managed to complete the solid color script.

Thank you once again.

Last changed by Thiago_Sase on 7/17/2024, 6:45 PM, 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

Thiago_Sase wrote on 7/17/2024, 8:37 PM

@Steve_Rhoden There is a post where @marcinzm talks about of a possible way to do the push button analyse automatically, i don't know if works, because i don't have Prodad Mercalli V5;

https://www.vegascreativesoftware.info/us/forum/apply-plugin-and-run-analyze-button-via-script--140597/#ca877791

I just added the line of code;

if ((ofxparm.ParameterType.ToString()=="PushButton") &&  (ofxparm.Label == "Analyze"))

as @Robert Johnston pointed out.

 

 

using System;
using ScriptPortal.Vegas;
using System.IO;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
public class EntryPoint
{    Vegas myVegas;    public void FromVegas(Vegas vegas)
    {        myVegas = vegas;
        string p_czy_usunac_efekt="TN";
        
        DialogResult dialogResult = MessageBox.Show("Czy zastosować efekt dot. stabilizacji video ProDad Marcalli v4 i uruchomić automatycznie stabilizację?", "Pytanie o stablizację ujęć", MessageBoxButtons. YesNoCancel);
        if(dialogResult == DialogResult. Yes)
        {
            //kod jest nizej
        }
        else if (dialogResult == DialogResult.No)
        {
                return;
        }
        else
        {
            return;        
        }
        
        foreach (Track track in myVegas.Project.Tracks)
        {
                if (track.IsAudio())
                {
                    continue;
                }                foreach (TrackEvent evnt in track.Events)
                {                    if (!evnt.Selected)
                    {
                        continue;
                    }                    var plugInName="{Svfx:com.proDAD:StabilizerV4}";
                    var fx = myVegas.VideoFX;                    /*if (effect.PlugIn.UniqueID == effID)*/                    /*foreach (PlugInNode fx1 in myVegas.VideoFX)
                    {
                        string s = fx1.Name + " - " + fx1.ClassID + " UID: " + fx1.UniqueID + "  isOFX: " + fx1.IsOFX+Environment.NewLine;
                        File.AppendAllText(@"d:\PluginX.txt",s);
                    }*/                    var plugIn = fx.GetChildByUniqueID(plugInName);
                    
                    if (null == plugIn)
                    {
                        MessageBox.Show("Nie znaleziono plug-in o nazwie: '"+plugInName+"'");
                        return;
                    }
                    VideoEvent vEvnt=(VideoEvent)evnt;                    foreach (Effect ve in vEvnt.Effects)
                    {
                        if (ve.PlugIn.UniqueID==plugInName)
                        {                            if (p_czy_usunac_efekt.Equals("TN"))
                            {
                                DialogResult dialogResult1 = MessageBox.Show("Zauważyłem, że wcześniej już dodano efekt stabilizujcy proDAD Marcalli v4? Czy usunąć nadany wcześniej efekt i uruchomić analizowanie stabilizacji jeszcze raz?"+Environment.NewLine+Environment.NewLine+"UWAGA!!! Zmiana zostanie zastosowana do wszystkich klipów.", "Pytanie o usunięcie stablizacji ujęć", MessageBoxButtons. YesNoCancel);
                                if(dialogResult1 == DialogResult.Yes)
                                {
                                    p_czy_usunac_efekt="T";
                                }
                                else if(dialogResult1 == DialogResult.No)
                                {
                                    p_czy_usunac_efekt="N";
                                }
                                else
                                {
                                        return;
                                }
                            }
                            
                            if (p_czy_usunac_efekt.Equals("T"))
                            {
                                vEvnt.Effects.Remove(ve);
                            }
                        }
                    }
                    var effectX = new Effect (plugIn);
                    vEvnt.Effects.Add(effectX);                    /*if (null!=presetName)
                    {
                        effect.Preset = presetName;
                    }*/                    if (effectX.PlugIn.IsOFX)
                    {
                        OFXEffect ofx = effectX.OFXEffect;
                        foreach (OFXParameter ofxparm in ofx.Parameters)
                        {
                            if ((ofxparm.ParameterType.ToString()=="PushButton") &&  (ofxparm.Label == "Analyze"))
                            {
                                ofxparm.ParameterChanged();
                            }
                        }                    }
            }
            
        }
        
        
    }    }

 

Last changed by Thiago_Sase on 7/17/2024, 8:41 PM, changed a total of 2 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

Steve_Rhoden wrote on 7/17/2024, 10:55 PM

@Thiago_Sase Yeah, i know that script already, but its not streamlined. You often have to initiate it twice for it to work.

jetdv wrote on 7/18/2024, 8:48 AM

@Steve_Rhoden I don't have the Prodad version, as far as I am aware, to do any testing.

Steve_Rhoden wrote on 7/18/2024, 9:24 AM

@jetdv Here is the trial link if so needed: https://www.prodad.de/support/mercalli/mercalli-50-vegas64bit.exe

However after the installation, you have to copy all its folders from the default ofx plugins location to the Vegas Pro OFX Video Plugins folder, for Vegas to recognize it.

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

@Steve_Rhoden, I don't like installing unwanted/unneeded software onto my system. But I would think this script would work just fine there as well by changing the information related to which plugin to add and the name of the button to press. Naturally, I'd take out the three lines that changes the "Views" as well as that also won't apply but I don't know if there's something similar that might need to be changed in Prodad before pushing the button. The Prodad script shown above looks a lot more complicated (and I can't read the message contents) so it might work the first time if simplified... In other words, you might just try 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;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            string plugInUID = "{Svfx:com.proDAD:StabilizerV4}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            evnt.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;

                            evnt.OpenVideoEffectUI();

                            foreach (OFXParameter parm in ofx.Parameters)
                            {
                                if (parm.ParameterType.ToString() == "PushButton" && ofxparm.Label == "Analyze")
                                {
                                    parm.ParameterChanged();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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

 

Steve_Rhoden wrote on 7/18/2024, 10:15 AM

@jetdv sorry, doesn't work. keeps throwing an "ofxparm" error, saying it does not exist.... Thanks still for the effort.

jetdv wrote on 7/18/2024, 10:18 AM

Sorry, the problem is right here. Change this section - I'll bold the important part:

                            foreach (OFXParameter parm in ofx.Parameters)
                            {
                                if (parm.ParameterType.ToString() == "PushButton" && ofx.Label == "Analyze")
                                {
                                    parm.ParameterChanged();
                                }
                            }

 

Thiago_Sase wrote on 9/7/2024, 1:44 PM

@Steve_Rhoden I did the download as you mentioned;

Here is the trial link if so needed: https://www.prodad.de/support/mercalli/mercalli-50-vegas64bit.exe

I also followed those steps;

However after the installation, you have to copy all its folders from the default ofx plugins location to the Vegas Pro OFX Video Plugins folder, for Vegas to recognize it.

And, since the day you mentioned that Plugin, I was trying to find a solution for it. So, today I finally got it. Now, the Prodad Mercalli V5 plugin works as the same as the final script of Vegas Video Stabilization OFX plugin made by @jetdv.

Here's the code, Have fun;
 

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 evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            string plugInUID = "{Svfx:com.proDAD:StabilizerV4}";

                            PlugInNode fx = myVegas.VideoFX;
                            PlugInNode plugin = fx.GetChildByUniqueID(plugInUID);
                            Effect effect = new Effect(plugin);
                            evnt.Effects.Add(effect);

                            OFXEffect ofx = effect.OFXEffect;


                            evnt.OpenVideoEffectUI();

                            foreach (OFXParameter parm in ofx.Parameters)
                            {
                                if (parm.ParameterType.ToString() == "PushButton" && parm.Name == "AnalysisParam")
                                {
                                    parm.ParameterChanged();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}

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 9/7/2024, 2:09 PM, changed a total of 6 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