How to prevent auto-resize? What's the point of "disable resample"?

Comments

Robert Johnston wrote on 10/6/2023, 6:14 PM

@john_dennis @jetdv @VideoVibrance I could be mistaken, but I believe the OP wanted Unscale To Stream Size. The width and height of the project should be used for the width and height in the pan/crop settings. Anyway, I was working on a script that does that, except it only works with the first keyframe, and lacks the robustness of Ed's script. I'm just a newbee. If it weren't for jetdv, I wouldn't have made it this far.

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 UnscaleToStreamSize
{
    public class Class1

    {
        public Vegas myVegas;


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

            int numTracks = myVegas.Project.Tracks.Count;
            //for (int i = 0; i < numTracks; i++)
            foreach (Track track in myVegas.Project.Tracks)
            {
                foreach (TrackEvent evnt in track.Events)
                {
                    foreach (Take take in evnt.Takes)
                    {
                        if (take.IsActive)
                        {
                            if (evnt.Selected)
                            {


                                if (evnt.IsVideo())
                                {

                                    // By the way, all takes will be affected because they all share the same keyframes

                                    VideoEvent vEvent = (VideoEvent)evnt;

                                    //Get project width x height
                                    Project vproject = myVegas.Project;
                                    int projectVideoWidth = vproject.Video.Width;
                                    int projectVideoHeight = vproject.Video.Height;

                                    // Calculate offsets needed to center video within frame
                                    //VideoStream vs = (VideoStream)media.Streams[0];
                                    VideoStream vStream = (VideoStream)vEvent.ActiveTake.Media.Streams.GetItemByMediaType(MediaType.Video, vEvent.ActiveTake.StreamIndex);

                                    float voffsetW = (vStream.Width - projectVideoWidth) / 2;
                                    float voffsetH = (vStream.Height - projectVideoHeight) / 2;

                                    //Get first keyframe for event
                                    VideoMotionKeyframe vmkf = vEvent.VideoMotion.Keyframes[0];
                                    //Get bounds from first keyframe
                                    VideoMotionBounds vmb = vmkf.Bounds;
                                    //Set new bounds
                                    vmb.TopLeft = new VideoMotionVertex(voffsetW, voffsetH);
                                    vmb.TopRight = new VideoMotionVertex((float)projectVideoWidth + voffsetW, voffsetH);
                                    vmb.BottomRight = new VideoMotionVertex((float)projectVideoWidth + voffsetW, (float)projectVideoHeight + voffsetH);
                                    vmb.BottomLeft = new VideoMotionVertex(voffsetW, (float)projectVideoHeight + voffsetH);

                                    vmkf.Bounds = vmb;
                                }
                            }
                        }  
                    }
                }
            }
        }
    }
}

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

Intel Core i7 10700K CPU @ 3.80GHz (to 4.65GHz), NVIDIA GeForce RTX 2060 SUPER 8GBytes. Memory 32 GBytes DDR4. Also Intel UHD Graphics 630. Mainboard: Dell Inc. PCI-Express 3.0 (8.0 GT/s) Comet Lake. Bench CPU Multi Thread: 5500.5 per CPU-Z.

Vegas Pro 21.0 (Build 108) with Mocha Vegas

Windows 11 not pro

john_dennis wrote on 10/6/2023, 7:39 PM

@Robert Johnston Your script appears to work for my 500 x 500 pixel test case.