Comments

3POINT wrote on 10/28/2024, 9:51 AM

Probably you're using the pancrop tool for moving the png. Make sure before moving the png that the aspect ratio of the pancrop tool is according your project and not according the aspect ratio of your source png. To do so right click in the pancrop window and select "Match output aspect":

jetdv wrote on 10/28/2024, 9:51 AM

Try Track Motion.

If you try with Pan/Crop, make sure you right-click the Pan/Crop screen and choose "Match Output Aspect" first. Then Pan/Crop will move it to the edge of the screen.

You can also use the Picture-in-Picture effect.

bitman wrote on 11/1/2024, 2:43 AM

@3POINT @jetdv I cannot believe I have not discovered this solution (using right click and select match output aspect) before!

All these past years I am using Vegas, I was always plagued by the poster's issue when using pan crop for PIP effects. And I use pan crop a lot. I always solved the issue by adding the "Picture in picture" effect. Now I learned something new just by reading over the forum ... Thanks again, one is never to old to learn!

Just as a side note, do not search for "Picture-In-Picture" in Vegas, search for "Picture In Picture".

Plugin "Picture-In-Picture" is from NewblueFX, "Picture In Picture" is a native Vegas plugin. I have both by the way.

APPS: VIDEO: VP 365 suite (VP 22 build 194) VP 21 build 315, VP 365 20, VP 19 post (latest build -651), (uninstalled VP 12,13,14,15,16 Suite,17, VP18 post), Vegasaur, a lot of NEWBLUE plugins, Mercalli 6.0, Respeedr, Vasco Da Gamma 17 HDpro XXL, Boris Continuum 2025, Davinci Resolve Studio 18, SOUND: RX 10 advanced Audio Editor, Sound Forge Pro 18, Spectral Layers Pro 10, Audacity, FOTO: Zoner studio X, DXO photolab (8), Luminar, Topaz...

  • OS: Windows 11 Pro 64, version 24H2 (since October 2024)
  • CPU: i9-13900K (upgraded my former CPU i9-12900K),
  • Air Cooler: Noctua NH-D15 G2 HBC (September 2024 upgrade from Noctua NH-D15s)
  • RAM: DDR5 Corsair 64GB (5600-40 Vengeance)
  • Graphics card: ASUS GeForce RTX 3090 TUF OC GAMING (24GB) 
  • Monitor: LG 38 inch ultra-wide (21x9) - Resolution: 3840x1600
  • C-drive: Corsair MP600 PRO XT NVMe SSD 4TB (PCIe Gen. 4)
  • Video drives: Samsung NVMe SSD 2TB (980 pro and 970 EVO plus) each 2TB
  • Mass Data storage & Backup: WD gold 6TB + WD Yellow 4TB
  • MOBO: Gigabyte Z690 AORUS MASTER
  • PSU: Corsair HX1500i, Case: Fractal Design Define 7 (PCGH edition)
  • Misc.: Logitech G915, Evoluent Vertical Mouse, shuttlePROv2

 

 

Gid wrote on 11/1/2024, 5:20 AM

@bitman Hi, have you tried this script, I should thank @jetdv for 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;

            float scrWidth = myVegas.Project.Video.Width;
            float scrHeight = myVegas.Project.Video.Height;

            foreach (Track myTrack in myVegas.Project.Tracks)
            {
                if (myTrack.IsVideo())
                {
                    foreach (VideoEvent evnt in myTrack.Events)
                    {
                        if (evnt.Selected)
                        {
                            MatchAspect(evnt);

                            VideoEvent videoEvent = evnt as VideoEvent;
                            VideoMotionKeyframes keyframes = videoEvent.VideoMotion.Keyframes;
                            int cKeyframes = keyframes.Count;
                            for (int jj = cKeyframes - 1; jj >= 0; jj--)
                            {
                                VideoMotionKeyframe thisKeyframe = keyframes[jj] as VideoMotionKeyframe;

                                float dWidth = Math.Abs(thisKeyframe.TopRight.X - thisKeyframe.TopLeft.X);
                                float dHeight = Math.Abs(thisKeyframe.BottomLeft.Y - thisKeyframe.TopLeft.Y); ;

                                MediaStream mediaStream = GetActiveMediaStream(videoEvent);
                                VideoStream videoStream = mediaStream as VideoStream;
                                VideoOutputRotation vRotation = videoStream.Rotation;

                                float dFullHeight = videoStream.Height;
                                float dFullWidth = videoStream.Width;
                                if ((vRotation == VideoOutputRotation.QuarterTurnClockwise) || (vRotation == VideoOutputRotation.QuarterTurnCounterclockwise))
                                {
                                    dFullHeight = videoStream.Width;
                                    dFullWidth = videoStream.Height;
                                }

                                float pwid = 0.0F;
                                float wpwid = 0.0F;
                                bool smaller = false;

                                if (dFullHeight > scrHeight)
                                {
                                    pwid = dFullHeight / dHeight * 100;
                                }
                                else
                                {
                                    pwid = dHeight / dFullHeight * 100;
                                    smaller = true;
                                }

                                if (dFullWidth > scrWidth)
                                {
                                    smaller = false;
                                    wpwid = dFullWidth / dWidth * 100;
                                }
                                else
                                {
                                    wpwid = dWidth / dFullWidth * 100;
                                }

                                if (wpwid > pwid && !smaller)
                                {
                                    pwid = wpwid;
                                }
                                if (wpwid < pwid && smaller)
                                {
                                    pwid = wpwid;
                                }

                                ScaleKeyframe(thisKeyframe, pwid, 0);
                            }
                        }
                    }
                }
            }
        }

        public void MatchAspect(TrackEvent trackEvent)
        {
            float dWidthProject = myVegas.Project.Video.Width;
            float dHeightProject = myVegas.Project.Video.Height;
            double dPixelAspect = myVegas.Project.Video.PixelAspectRatio;
            double dAspect = dPixelAspect * dWidthProject / dHeightProject;

            MediaStream mediaStream = GetActiveMediaStream(trackEvent);
            if (!(mediaStream == null))
            {
                VideoStream videoStream = mediaStream as VideoStream;

                double dMediaPixelAspect = videoStream.PixelAspectRatio;
                VideoEvent videoEvent = trackEvent as VideoEvent;
                VideoMotionKeyframes keyframes = videoEvent.VideoMotion.Keyframes; ;

                int cKeyframes = keyframes.Count;

                for (int jj = cKeyframes - 1; jj >= 0; jj--)
                {
                    VideoMotionKeyframe thisKeyframe = keyframes[jj] as VideoMotionKeyframe;
                    MatchOutputAspect(thisKeyframe, dMediaPixelAspect, dAspect);
                }
            }
            myVegas.UpdateUI();
        }

        public MediaStream GetActiveMediaStream(TrackEvent trackEvent)
        {
            try
            {
                if (!(trackEvent.ActiveTake.IsValid()))
                {
                    throw new ArgumentException("empty or invalid take");
                }

                Media media = myVegas.Project.MediaPool.Find(trackEvent.ActiveTake.MediaPath);
                if (null == media)
                {
                    MessageBox.Show("missing media");
                    throw new ArgumentException("missing media");
                }

                MediaStream mediaStream = media.Streams.GetItemByMediaType(MediaType.Video, trackEvent.ActiveTake.StreamIndex);
                return mediaStream;
            }
            catch (Exception e)
            {
                MessageBox.Show("{0}", e.Message);
                return null;
            }
        }


        public void MatchOutputAspect(VideoMotionKeyframe keyframe, double dMediaPixelAspect, double dAspectOut)
        {
            VideoMotionKeyframe keyframeSave = keyframe;

            try
            {
                double rotation = keyframe.Rotation;
                keyframe.RotateBy(-rotation);

                float dWidth = Math.Abs(keyframe.TopRight.X - keyframe.TopLeft.X);
                float dHeight = Math.Abs(keyframe.BottomLeft.Y - keyframe.TopLeft.Y);
                double dCurrentAspect = dMediaPixelAspect * dWidth / dHeight;
                float centerY = keyframe.Center.Y;
                float centerX = keyframe.Center.X;
                double dFactor;

                VideoMotionBounds bounds = new VideoMotionBounds(keyframe.TopLeft, keyframe.TopRight, keyframe.BottomRight, keyframe.BottomLeft);
                if (dCurrentAspect < dAspectOut)
                {
                    // alter y coords            
                    dFactor = dCurrentAspect / dAspectOut;

                    bounds.TopLeft.Y = (bounds.TopLeft.Y - centerY) * (float)dFactor + centerY;
                    bounds.TopRight.Y = (bounds.TopRight.Y - centerY) * (float)dFactor + centerY;
                    bounds.BottomLeft.Y = (bounds.BottomLeft.Y - centerY) * (float)dFactor + centerY;
                    bounds.BottomRight.Y = (bounds.BottomRight.Y - centerY) * (float)dFactor + centerY;
                }
                else
                {
                    // alter x coords
                    dFactor = dAspectOut / dCurrentAspect;

                    bounds.TopLeft.X = (bounds.TopLeft.X - centerX) * (float)dFactor + centerX;
                    bounds.TopRight.X = (bounds.TopRight.X - centerX) * (float)dFactor + centerX;
                    bounds.BottomLeft.X = (bounds.BottomLeft.X - centerX) * (float)dFactor + centerX;
                    bounds.BottomRight.X = (bounds.BottomRight.X - centerX) * (float)dFactor + centerX;
                }

                // set it to new bounds
                keyframe.Bounds = bounds;

                // restore rotation.        
                keyframe.RotateBy(rotation);
            }
            catch
            {
                // restore original settings on error
                keyframe = keyframeSave;
            }
        }

        public void ScaleKeyframe(VideoMotionKeyframe keyframe, float szChange, float rotAngle)
        {
            float cWidth = (1 / (szChange / 100));
            float cHeight = (1 / (szChange / 100));

            if (szChange > 100)
            {
                cWidth = (szChange / 100);
                cHeight = (szChange / 100);
            }

            VideoMotionVertex bounds = new VideoMotionVertex(cWidth, cHeight);

            keyframe.ScaleBy(bounds);
            keyframe.RotateBy((rotAngle * (Math.PI / 180)));
        }

    }
}

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

 

Vegas Pro 18 - 22
Vegas Pro/Post 19
Boris Continuum & Sapphire, 
Silhouette Standalone + Plugin, 
Mocha Pro Standalone + Plugin, 
Boris Optics,
NewBlue TotalFX
Desktop PC Microsoft Windows 10 Pro - 64-Bit
ASUS PRO WS WRX80E-SAGE SE WIFI AMD Motherboard
AMD Ryzen Threadripper PRO 3975WX 3.5GHz 32 Core
Corsair iCUE H150i RGB PRO XT 360mm All-in-One Liquid CPU Cooler
RAM 256GB ( 8x Micron 32GB (1x 32GB) 2666MHz DDR4 RAM )
2x Western Digital Black SN850 2TB M.2-2280 SSD, 7000MB/s Read, 5100MB/s Write
(programs on one, project files on the other)
Graphics MSI GeForce RTX 3090 SUPRIM X 24GB OC GPU
ASUS ROG Thor 1200W Semi-Modular 80+ Platinum PSU 
Fractal Design Define 7 XL Dark TG Case with 3 Fans
Dell SE3223Q 31.5 Inch 4K UHD (3840x2160) Monitor, 60Hz, & an Acer 24" monitor.

At the moment my filming is done with a Samsung Galaxy S23 Ultra 5G & a GoPro Hero11 Black

I've been a Joiner/Carpenter for 40yrs, apprentice trained time served, I don't have an apprentice of my own so to share my knowledge I put videos on YouTube.

YouTube videos - https://www.youtube.com/c/Gidjoiner

 

3POINT wrote on 11/1/2024, 5:20 AM

@bitman Indeed, never to old to learn. You even can make Vegas doing this output aspect ratio matching automatically by enabling following feature in the preferences:

bitman wrote on 11/3/2024, 12:55 PM

@Gid @jetdv Thanks! I have added the script to my collection and named it "Aspect" which I think it covers it nicely in brief and name!

APPS: VIDEO: VP 365 suite (VP 22 build 194) VP 21 build 315, VP 365 20, VP 19 post (latest build -651), (uninstalled VP 12,13,14,15,16 Suite,17, VP18 post), Vegasaur, a lot of NEWBLUE plugins, Mercalli 6.0, Respeedr, Vasco Da Gamma 17 HDpro XXL, Boris Continuum 2025, Davinci Resolve Studio 18, SOUND: RX 10 advanced Audio Editor, Sound Forge Pro 18, Spectral Layers Pro 10, Audacity, FOTO: Zoner studio X, DXO photolab (8), Luminar, Topaz...

  • OS: Windows 11 Pro 64, version 24H2 (since October 2024)
  • CPU: i9-13900K (upgraded my former CPU i9-12900K),
  • Air Cooler: Noctua NH-D15 G2 HBC (September 2024 upgrade from Noctua NH-D15s)
  • RAM: DDR5 Corsair 64GB (5600-40 Vengeance)
  • Graphics card: ASUS GeForce RTX 3090 TUF OC GAMING (24GB) 
  • Monitor: LG 38 inch ultra-wide (21x9) - Resolution: 3840x1600
  • C-drive: Corsair MP600 PRO XT NVMe SSD 4TB (PCIe Gen. 4)
  • Video drives: Samsung NVMe SSD 2TB (980 pro and 970 EVO plus) each 2TB
  • Mass Data storage & Backup: WD gold 6TB + WD Yellow 4TB
  • MOBO: Gigabyte Z690 AORUS MASTER
  • PSU: Corsair HX1500i, Case: Fractal Design Define 7 (PCGH edition)
  • Misc.: Logitech G915, Evoluent Vertical Mouse, shuttlePROv2