pip rotating a line while showing the degrees. Is it possible in Vega

wilco-n wrote on 6/11/2025, 10:40 PM

I'm using pip that is controlling a line across the screen.

The line is created using pan/crop and using the mask to create the thin red line I want.

I then use pip to place the line where I want it.

Their is an object on the screen that is rotating and I want to follow it with the red line and what the angle is as it rotates.

Two problems I having.

1. The red line doesn't stay on the dead centre of the object as it moves slightly.

2. I can't work out how I can get the degrees that are shown in pip to be displayed.

I have tried using tracking but it is not working very well actually it doesn't really work. I don't have mocha.

Is there any tools out there that could actually do what I am trying to do?

 

Separate question.

I don't have any history of my previous posts. Do the previous questions history get removed from your profile?

Thanks in advance.

Comments

EricLNZ wrote on 6/11/2025, 11:14 PM

I don't have any history of my previous posts. Do the previous questions history get removed from your profile?

They are still there. Do you not see this when you go into your profile?

john_dennis wrote on 6/12/2025, 2:13 AM

Something like this?

wilco-n wrote on 6/12/2025, 3:45 AM

Something like this?

 

WOW yeah like that! Thanks for the doing that.

Now how did you do it. 😀

wilco-n wrote on 6/12/2025, 3:50 AM

I don't have any history of my previous posts. Do the previous questions history get removed from your profile?

They are still there. Do you not see this when you go into your profile?

I do now but I didn't before. I have a slow internet could it be the forum takes awhile to fill in the profile data?

I also found it very slow to get to the forum but I don't have the same problem with another forum I go to.

Thanks for checking.

Did you do something to make it work?

 

 

EricLNZ wrote on 6/12/2025, 4:41 AM

Did you do something to make it work?

No, nothing. Perhaps as you suspect it was slow internet connection.

john_dennis wrote on 6/12/2025, 10:20 AM

@wilco-n

Here is a PNG Image Sequence of the "finished" rotating line.

Google Drive Link

Drop it over your video, rotate and size to suit.

Here are the projects that I used.

Projects Here

Feel free to reverse engineer the projects to suit your needs.

It only took me a few minutes to do the task last night but it's likely to take much longer to 'splane it today with the other tasks that I have to do.

wilco-n wrote on 6/12/2025, 5:34 PM

@wilco-n

Here is a PNG Image Sequence of the "finished" rotating line.

Google Drive Link

Drop it over your video, rotate and size to suit.

Here are the projects that I used.

Projects Here

Feel free to reverse engineer the projects to suit your needs.

It only took me a few minutes to do the task last night but it's likely to take much longer to 'splane it today with the other tasks that I have to do.

Thank you for doing this.

I am using Vegas pro 21 which can't open the .veg files it says they are a newer version and can't be opened.

I can see what you have done with the images and the line. It seems like a lot of work to get the line and the degree to match unless you have an automated way of creating that. Perhaps the .veg files would have helped me here.

I appreciate the time and effort you put in to this.

 

john_dennis wrote on 6/12/2025, 6:39 PM

@wilco-n

I have gotten around to doing this in Vegas 13. You should be able to open these projects:

Rotating Lines Projects

The way the sausage was made can be seen in this unlisted video from Howie Duit.

Even the way I type it can be done in ~10 minutes.

zzzzzz9125 wrote on 6/12/2025, 8:20 PM

@wilco-n How about such a script? It reads the Angle values of PIP and converts them into Titles And Text. It can read any Titles And Text presets.

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;

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 Text_Class
    {
        public Vegas myVegas;
        public const string UID_PICTURE_IN_PICTURE = "{Svfx:com.vegascreativesoftware:pictureinpicture}";
        public const string UID_PICTURE_IN_PICTURE_SONY = "{Svfx:com.sonycreativesoftware:pictureinpicture}";
        public const string NAME_PARAMETER = "Angle";
        public const string UID_TITLES_AND_TEXT = "{Svfx:com.vegascreativesoftware:titlesandtext}";
        public const string UID_TITLES_AND_TEXT_SONY = "{Svfx:com.sonycreativesoftware:titlesandtext}";
        public void Main(Vegas vegas)
        {
            myVegas = vegas;
            myVegas.ResumePlaybackOnScriptExit = true;

            if (vegas.Project.Tracks.Count == 0)
            {
                return;
            }

            PlugInNode plugPIP = myVegas.VideoFX.FindChildByUniqueID(UID_PICTURE_IN_PICTURE) ?? myVegas.VideoFX.FindChildByUniqueID(UID_PICTURE_IN_PICTURE_SONY);
            PlugInNode plugTAT = myVegas.Generators.FindChildByUniqueID(UID_TITLES_AND_TEXT) ?? myVegas.Generators.FindChildByUniqueID(UID_TITLES_AND_TEXT_SONY);

            if (plugPIP == null)
            {
                MessageBox.Show("PlugIn \"Picture In Picture\" Not Found!");
                return;
            }

            if (plugTAT == null)
            {
                MessageBox.Show("PlugIn \"Titles & Text\" Not Found!");
                return;
            }

            List<VideoEvent> evs = new List<VideoEvent>();

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (TrackEvent ev in myTrack.Events)
                    {
                        if (ev.Selected)
                        {
                            evs.Add((VideoEvent)ev);
                        }
                    }
                }
            }

            if (evs.Count == 0)
            {
                return;
            }

            EffectPresets efPresets = plugTAT.Presets;
            string[] presets = new string[efPresets.Count];
            for (int i = 0; i < efPresets.Count; i++)
            {
                presets[i] = efPresets[i].Name;
            }

            string presetName = null;
            if (!ShowWindow(presets, out presetName))
            {
                return;
            }

            foreach (VideoEvent ev in evs)
            {
                Track currentTrack = ev.Track;
                foreach (Effect ef in ev.Effects)
                {
                    if (ef.PlugIn.IsOFX && ef.PlugIn.UniqueID == plugPIP.UniqueID)
                    {
                        OFXDoubleParameter para = ef.OFXEffect.FindParameterByName(NAME_PARAMETER) as OFXDoubleParameter;
                        if (para != null && para.IsAnimated)
                        {
                            int trackIndex = currentTrack.Index - 1;
                            VideoTrack trk;
                            if (trackIndex > -1 && myVegas.Project.Tracks[trackIndex].IsVideo())
                            {
                                trk = myVegas.Project.Tracks[trackIndex] as VideoTrack;
                            }
                            else
                            {
                                trackIndex += 1;
                                trk = new VideoTrack(myVegas.Project, trackIndex, null);
                                myVegas.Project.Tracks.Add(trk);
                            }

                            Media m = Media.CreateInstance(myVegas.Project, plugTAT, presetName);
                            m.Generator.Preset = presetName;
                            m.Length = ev.Length;
                            VideoEvent vEv = trk.AddVideoEvent(ev.Start, m.Length);
                            vEv.AddTake(m.GetVideoStreamByIndex(0));

                            if (m.Generator.PlugIn.IsOFX)
                            {
                                OFXStringParameter paraText = m.Generator.OFXEffect.FindParameterByName("Text") as OFXStringParameter;
                                if (paraText != null)
                                {
                                    RichTextBox rtb = new RichTextBox { Rtf = paraText.Value };
                                    paraText.IsAnimated = true;
                                    string lastValue = null;
                                    for (int i = 0; i <= m.Length.FrameCount; i++)
                                    {
                                        Timecode t = Timecode.FromFrames(i);
                                        rtb.Text = para.GetValueAtTime(t).ToString("F0");
                                        if (rtb.Rtf != lastValue)
                                        {
                                            paraText.SetValueAtTime(t, rtb.Rtf);
                                            lastValue = rtb.Rtf;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        public bool ShowWindow(string[] presets, out string presetName)
        {
            Form form = new Form
            {
                ShowInTaskbar = false,
                AutoSize = true,
                BackColor = Color.FromArgb(45, 45, 45),
                ForeColor = Color.FromArgb(200, 200, 200),
                Font = new Font("Arial", 9),
                Text = "PIP Angle To Text",
                FormBorderStyle = FormBorderStyle.FixedToolWindow,
                StartPosition = FormStartPosition.CenterScreen,
                AutoSizeMode = AutoSizeMode.GrowAndShrink
            };

            Panel p = new Panel
            {
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink
            };
            form.Controls.Add(p);

            TableLayoutPanel l = new TableLayoutPanel
            {
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                GrowStyle = TableLayoutPanelGrowStyle.AddRows,
                ColumnCount = 2
            };
            p.Controls.Add(l);

            Label label = new Label
            {
                Margin = new Padding(12, 9, 6, 6),
                Text = "Preset",
                AutoSize = true
            };
            l.Controls.Add(label);

            ComboBox cb = new ComboBox()
            {
                DataSource = presets,
                DropDownStyle = ComboBoxStyle.DropDownList,
                Margin = new Padding(6, 6, 6, 6),
                Dock = DockStyle.Fill
            };
            l.Controls.Add(cb);

            FlowLayoutPanel panel = new FlowLayoutPanel
            {
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                Anchor = AnchorStyles.None,
                Font = new Font("Arial", 8)
            };
            l.Controls.Add(panel);
            l.SetColumnSpan(panel, 2);

            Button ok = new Button
            {
                Text = "OK",
                DialogResult = DialogResult.OK
            };
            panel.Controls.Add(ok);
            form.AcceptButton = ok;

            Button cancel = new Button
            {
                Text = "Cancel",
                DialogResult = DialogResult.Cancel
            };
            panel.Controls.Add(cancel);
            form.CancelButton = cancel;

            DialogResult result = form.ShowDialog(myVegas.MainWindow);
            presetName = cb.SelectedItem.ToString();
            return result == DialogResult.OK;
        }
    }
}

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

 

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