Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums VEGAS Pro Sony Vegas Scripting … moving a video to a different track

  • Sony Vegas Scripting … moving a video to a different track

    Posted by Austin Brock on February 8, 2013 at 2:23 pm

    Trying to write some code to move a video to track 1 if the track is muted, and to track 2 if the track is not muted (after a multicam edit).

    So far I have this…

    using Sony.Vegas;

    public class EntryPoint
    {
    public void FromVegas(Vegas app)
    {
    foreach (Sony.Vegas.Track currentTrack in app.Project.Tracks)
    {
    if (currentTrack.IsAudio())
    continue;

    foreach (Sony.Vegas.TrackEvent currentEvent in currentTrack.Events)
    {
    if (currentEvent.Mute == true)
    {
    // Move to track 1
    } else {
    // Move to track 2
    }
    }
    }
    }
    }

    I’m hoping to resize and position the clip afterward to create a smaller view of the muted clip (after toggling it to unmuted), so that you can see both cameras, but the chosen camera will be the full view.

    I hope this makes sense :).

    John Rofrano replied 13 years, 3 months ago 3 Members · 5 Replies
  • 5 Replies
  • Edward Troxel

    February 8, 2013 at 5:52 pm

    You can just change the track number:

    CurrentEvent.Track = 0; //For track 1. However that will mess up your loop.

    I usually just copy them to the new track so the original is left alone:

    CurrentEvent.Copy(0, CurrentEvent.Start); //For Track 1

    Edward Troxel

  • Austin Brock

    February 8, 2013 at 5:57 pm

    Cannot implicitly convert type 'int' to 'Sony.Vegas.Track' for currentEvent.Track = 0;

    The best overloaded method match for 'Sony.Vegas.TrackEvent.Copy(Sony.Vegas.Track, Sony.Vegas.Timecode)' has some invalid arguments
    Argument '1': cannot convert from 'int' to 'Sony.Vegas.Track'
    for CurrentEvent.Copy(0, CurrentEvent.Start);

  • John Rofrano

    February 9, 2013 at 12:54 am

    You need to use the actual Track object so first you need to determine which track is track 1 and which track is track 2. If you mean the actual 1st & 2nd track that would be app.Project.Tracks[0] and app.Project.Tracks[1] respectively.

    BTW, your code does not match your description. You said you wanted to move the event to track 1 if the track is muted yet you are testing to see if the event is muted. Which is correct?

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

  • Austin Brock

    February 9, 2013 at 9:07 am

    Thank you so much, John. That’s exactly what I needed.

    Basically after editing a multicam video using two videos, I wanted to move the videos that are not muted to the second track, and the videos not used to the first track. Then I plan to make the muted videos a small window in one of the corners and unmute them, so that the track 2 video is the large view, but you can see the track 1 video showing in the corner.

    This was my end result, it can only be executed ONCE per set of videos and is based on the default resolution of 1920×1080, but if I needed to modify anything, I could just mute the videos on track 1 before running the script again.

    VIDEO OF THE RESULT: https://www.youtube.com/watch?v=N8fdAfv0kAo

    using System.Windows.Forms;
    using Sony.Vegas;

    public class EntryPoint
    {
    public void FromVegas(Vegas app)
    {
    System.Collections.Generic.List muteWindow = new System.Collections.Generic.List();
    System.Collections.Generic.List normWindow = new System.Collections.Generic.List
    ();

    foreach (Sony.Vegas.Track currentTrack in app.Project.Tracks)
    {
    if (currentTrack.IsAudio())
    continue;

    foreach (Sony.Vegas.TrackEvent currentEvent in currentTrack.Events)
    {
    if (currentEvent.Mute == true)
    {
    // Move to track 1
    muteWindow.Add(currentEvent);

    } else {
    // Move to track 2
    normWindow.Add(currentEvent);
    }
    }
    }

    foreach (Sony.Vegas.Track currentTrack in app.Project.Tracks)
    {
    foreach (Sony.Vegas.TrackEvent currentEvent in muteWindow)
    {
    currentEvent.Track = app.Project.Tracks[0];
    }
    foreach (Sony.Vegas.TrackEvent currentEvent in normWindow)
    {
    currentEvent.Track = app.Project.Tracks[1];
    }
    }

    foreach (Sony.Vegas.TrackEvent currentEvent in muteWindow)
    {
    currentEvent.Mute = false;
    VideoTrack videoTrack = app.Project.Tracks[0] as VideoTrack;
    foreach (TrackMotionKeyframe keyframe in videoTrack.TrackMotion.MotionKeyframes)
    {
    keyframe.PositionX = -960+(480/2)+5;
    keyframe.PositionY = 540-(270/2)-5;
    keyframe.Width = 480;
    keyframe.Height = 270;
    }
    }
    }
    }

  • John Rofrano

    February 9, 2013 at 1:22 pm

    [Austin Brock] “This was my end result, it can only be executed ONCE per set of videos and is based on the default resolution of 1920×1080, but if I needed to modify anything, I could just mute the videos on track 1 before running the script again.”

    Nice work. One thing to consider is creating two new video tracks and copying the events instead of moving them. This will allow you to run the script multiple times because it will be non-destructive. This is how my VASST infinitiCAM and Ultimate S Pro handle multi-cam.

    ~jr

    http://www.johnrofrano.com
    http://www.vasst.com

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy