Comments

Former user wrote on 9/18/2019, 1:24 PM

Use Copy Motion Track to PIP Script

klapkowscy.com wrote on 9/19/2019, 3:05 AM

I did everything like in the movie and a window pops up for me

klapkowscy.com wrote on 9/19/2019, 3:06 AM

Maybe it's the fault that I'm using version 17 and the movie version 16

matthias-krutz wrote on 9/19/2019, 6:56 AM

I came across the same problem with the scripts in VP17.
There is a change in the determination of the x.Plugin.UniqueID.
If in the scripts "sonycreativsoftware" in "vegascreativsoftware" is changed, then it should work.

e.g.
x.PlugIn.UniqueID == "{Svfx:com.vegascreativesoftware:bzmasking}")

klapkowscy.com wrote on 9/19/2019, 8:06 AM

I came across the same problem with the scripts in VP17.
There is a change in the determination of the x.Plugin.UniqueID.
If in the scripts "sonycreativsoftware" in "vegascreativsoftware" is changed, then it should work.

e.g.
x.PlugIn.UniqueID == "{Svfx:com.vegascreativesoftware:bzmasking}")

I do not know what's going on. This is already something for the programmer

matthias-krutz wrote on 9/19/2019, 8:35 AM

Not complicated. Open the script with a text editor, and search for sonycreativsoftware and replace with vegascreativsoftware. Then save again as a script.

Desktop: Ryzen R7 2700, RAM 32 GB, X470 Aorus Ultra Gaming, Radeon RX 5700 8GB, Win10 2004

Laptop: T420, W10, i5-2520M 4GB, SSD, HD Graphics 3000

VEGAS Pro 14-18, Movie Studio 12 Platinum, Vegasaur, HOS, HitfilmPro

klapkowscy.com wrote on 9/19/2019, 9:54 AM

Not complicated. Open the script with a text editor, and search for sonycreativsoftware and replace with vegascreativsoftware. Then save again as a script.

I changed and still the same

matthias-krutz wrote on 9/19/2019, 10:34 AM

I just checked it again. In the "Copy Motion Track to PiP.cs" sonycreativesoftware is in two places to replace with vegascreativesoftware. Then it can be used in VP17.

    const string bzMaskingPlugin = "{Svfx:com.sonycreativesoftware:bzmasking}";

    const string pipPlugin = "{Svfx:com.sonycreativesoftware:pictureinpicture}";

_>

    const string bzMaskingPlugin = "{Svfx:com.vegascreativesoftware:bzmasking}";

    const string pipPlugin = "{Svfx:com.vegascreativesoftware:pictureinpicture}";

Desktop: Ryzen R7 2700, RAM 32 GB, X470 Aorus Ultra Gaming, Radeon RX 5700 8GB, Win10 2004

Laptop: T420, W10, i5-2520M 4GB, SSD, HD Graphics 3000

VEGAS Pro 14-18, Movie Studio 12 Platinum, Vegasaur, HOS, HitfilmPro

fr0sty wrote on 9/19/2019, 11:03 AM

Are you applying motion tracking with the bezier masking plugin to the video you want tracked first before you do the copy motion tracking data to pip script?

Systems:

Desktop

AMD Ryzen 7 1800x 8 core 16 thread at stock speed

64GB 3000mhz DDR4

Geforce RTX 3090

Windows 10

Laptop:

ASUS Zenbook Pro Duo 32GB (9980HK CPU, RTX 2060 GPU, dual 4K touch screens, main one OLED HDR)

klapkowscy.com wrote on 9/19/2019, 11:13 AM

Are you applying motion tracking with the bezier masking plugin to the video you want tracked first before you do the copy motion tracking data to pip script?

yes

klapkowscy.com wrote on 9/19/2019, 11:17 AM

I just checked it again. In the "Copy Motion Track to PiP.cs" sonycreativesoftware is in two places to replace with vegascreativesoftware. Then it can be used in VP17.

    const string bzMaskingPlugin = "{Svfx:com.sonycreativesoftware:bzmasking}";

    const string pipPlugin = "{Svfx:com.sonycreativesoftware:pictureinpicture}";

_>

    const string bzMaskingPlugin = "{Svfx:com.vegascreativesoftware:bzmasking}";

    const string pipPlugin = "{Svfx:com.vegascreativesoftware:pictureinpicture}";

for me it is changed in 2 places

 

/**
 * Copies the Location data (animation keyframes) from the first mask
 * of the selected video event's Bézier Masking FX to a selected
 * video event's Picture-In-Picture (PiP) FX
 *
 * To use this script:
 *
 * 1) Create track motion on an event using Bézier mask FX
 * 2) Apply a PiP FX to the event (from a different track) that you want to follow along with the motion on the original event
 * 3) Adjust location, scale and angle of PiP FX for a certain point in time.
 * 4) Select both events (hold ctrl key)
 * 5) Run the script
 *
 * Revision Date: Sep 5 2018
 * Copyright: MAGIX AG 
 **/
using System.Collections.Generic;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    Vegas myVegas;
    const string missingSelectionString = "Please select the video event to which you've applied tracking and the overlapping video event on a different track that holds the media you want to pin to the tracking.";
    const string missingTrackingDataString = "You must first apply the B\u00E9zier masking plug-in to one of the selected events and add motion tracking data for Mask 1.";
    const string missingPipFxString = "You must first add the Picture in Picture plug-in to the event that you want to pin to the motion tracked event.";

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

        VideoEvent bezierTrack = null;
        OFXDouble2DParameter locationTracking = null;

        List<TrackEvent> trackEvents = FindAllSelectedEventsUnderCursor();

        if (trackEvents.Count < 2)
        {
            MessageBox.Show(missingSelectionString, "No selected event", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return;
        }
        else
        {
            bool hasBezierFx = false;
            foreach (VideoEvent trackEvent in trackEvents)
            {
                List<Effect> fxList = new List<Effect>(trackEvent.Effects);
                Effect bezierFX = fxList.Find(x => (x.PlugIn.UniqueID == "{Svfx:com.vegascreativsoftware:bzmasking}"));
                hasBezierFx = bezierFX != null;

                if (hasBezierFx)
                {
                    List<OFXParameter> ofxList = new List<OFXParameter>(bezierFX.OFXEffect.Parameters);
                    OFXParameter param = ofxList.Find(x => (x.Name == "Location_0"));

                    if (param != null)
                    {
                        locationTracking = (OFXDouble2DParameter)param;
                        bezierTrack = trackEvent;
                        trackEvents.Remove(trackEvent);
                        break;
                    }
                }
            }
            if (!hasBezierFx)
            {
                MessageBox.Show(missingTrackingDataString, "VEGAS B\u00E9zier Masking not applied", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }

        if (locationTracking == null || locationTracking.Keyframes.Count == 0)
        {
            MessageBox.Show(missingTrackingDataString, "No tracking data", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return;
        }
        else
        {
            bool hasPipFx = false;
            foreach (VideoEvent trackEvent in trackEvents)
            {
                List<Effect> fxList = new List<Effect>(trackEvent.Effects);
                Effect pipFX = fxList.Find(x => (x.PlugIn.UniqueID == "{Svfx:com.vegascreativsoftware:pictureinpicture}"));
                hasPipFx = pipFX != null;

                if (hasPipFx)
                {
                    Timecode startDiff = trackEvent.Start - bezierTrack.Start;

                    List<OFXParameter> ofxList = new List<OFXParameter>(pipFX.OFXEffect.Parameters);
                    OFXParameter param = ofxList.Find(x => (x.Name == "Location"));

                    if (param != null)
                    {
                        OFXDouble2DParameter pipLocation = (OFXDouble2DParameter)param;

                        OFXDouble2D initLocationAtCursorPosition = pipLocation.GetValueAtTime(myVegas.Transport.CursorPosition);
                        OFXDouble2D locationAtCursorPosition = locationTracking.GetValueAtTime(myVegas.Transport.CursorPosition);
                        OFXDouble2D diff = new OFXDouble2D();
                        diff.X = locationAtCursorPosition.X - initLocationAtCursorPosition.X;
                        diff.Y = locationAtCursorPosition.Y - initLocationAtCursorPosition.Y;

                        pipLocation.Keyframes.Clear();

                        foreach (var keyframe in locationTracking.Keyframes)
                        {
                            OFXDouble2D tmpValue = keyframe.Value;
                            tmpValue.X -= diff.X;
                            tmpValue.Y -= diff.Y;
                            pipLocation.SetValueAtTime(keyframe.Time - startDiff, tmpValue);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(missingPipFxString, "No PiP FX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
        }
    }

    /// <summary>
    /// Returns the first selected event that's under the cursor
    /// </summary>
    /// <returns>The first selected event or null if no event selected</returns>
    List<TrackEvent> FindAllSelectedEventsUnderCursor()
    {
        List<TrackEvent> selectedEventsAcrossTracks = new List<TrackEvent>();

        foreach (Track track in myVegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected && trackEvent.Start <= myVegas.Transport.CursorPosition && trackEvent.End >= myVegas.Transport.CursorPosition)
                {
                    selectedEventsAcrossTracks.Add(trackEvent);
                }
            }
        }

        return selectedEventsAcrossTracks;
    }
}
 

matthias-krutz wrote on 9/19/2019, 12:46 PM

This is a very early version of the script. The current and already adapted version can be found in Tools-> Extensions, not in the scripting section.

Desktop: Ryzen R7 2700, RAM 32 GB, X470 Aorus Ultra Gaming, Radeon RX 5700 8GB, Win10 2004

Laptop: T420, W10, i5-2520M 4GB, SSD, HD Graphics 3000

VEGAS Pro 14-18, Movie Studio 12 Platinum, Vegasaur, HOS, HitfilmPro

klapkowscy.com wrote on 9/19/2019, 12:49 PM

To jest bardzo wczesna wersja skryptu. Bieżącą i już dostosowaną wersję można wykonać w Narzędzia-> Rozszerzenia, a nie w sekcji zastosowania skryptów.

you can provide a new version of the script

matthias-krutz wrote on 9/19/2019, 2:09 PM

In VP17, the script has become an extension.
Many more ways to use the motion tracking offers Vegasaur 3.9.

klapkowscy.com wrote on 9/20/2019, 2:12 AM

In VP17, the script has become an extension.
Many more ways to use the motion tracking offers Vegasaur 3.9.

OK thank you very much works. It is a pity that this tracking works only in the x, y plane but as the object moves away the subtitles remain the same size