Cutting a clip in equal parts

debojitacharjee wrote on 10/6/2022, 5:13 AM

I want to cut a clip either audio or video in equal parts of 10 seconds. I can do this using the selection tool and dragging it again and again over the timeline but that's not convenient and time taking. Is there any shortcut method of doing this and is there any hotkey to move the selection area back and forward over the timeline?

Comments

set wrote on 10/6/2022, 5:27 AM

Perhaps you can try make use of 'Empty Event':

Just right click on empty part of timeline, then 'Insert Empty Event', then adjust the length of that empty event, say as 10 seconds length, then use that object as reference 'ruler' for guide.

Setiawan Kartawidjaja
Bandung, West Java, Indonesia (UTC+7 Time Area)

Personal FB | Personal IG | Personal YT Channel
Chungs Video FB | Chungs Video IG | Chungs Video YT Channel
Personal Portfolios YouTube Playlist
Pond5 page: My Stock Footage of Bandung city

 

System 5-2021:
Processor: Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz   2.90 GHz
Video Card1: Intel UHD Graphics 630 (Driver 31.0.101.2127 (Feb 1 2024 Release date))
Video Card2: NVIDIA GeForce RTX 3060 Ti 8GB GDDR6 (Driver Version 551.23 Studio Driver (Jan 24 2024 Release Date))
RAM: 32.0 GB
OS: Windows 10 Pro Version 22H2 OS Build 19045.3693
Drive OS: SSD 240GB
Drive Working: NVMe 1TB
Drive Storage: 4TB+2TB

 

System 2-2018:
ASUS ROG Strix Hero II GL504GM Gaming Laptop
Processor: Intel(R) Core(TM) i7 8750H CPU @2.20GHz 2.21 GHz
Video Card 1: Intel(R) UHD Graphics 630 (Driver 31.0.101.2111)
Video Card 2: NVIDIA GeForce GTX 1060 6GB GDDR5 VRAM (Driver Version 537.58)
RAM: 16GB
OS: Win11 Home 64-bit Version 22H2 OS Build 22621.2428
Storage: M.2 NVMe PCIe 256GB SSD & 2.5" 5400rpm 1TB SSHD

 

* I don't work for VEGAS Creative Software Team. I'm just Voluntary Moderator in this forum.

jetdv wrote on 10/6/2022, 6:11 AM

You can write a script that will cut an event into whatever pieces you want.

FayFen wrote on 10/6/2022, 8:14 AM

As I'm in script mode today, I found a script just for that

/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/import ScriptPortal.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;//time intervals for split events.var Interval = "00:10:00";
try
{var IncTime : Timecode = new Timecode(Interval);// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;evnt.Split(IncTime);
}
}}catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

Copy that and save as SplitEvents.js file in your vegas script menu folder

Former user wrote on 10/6/2022, 10:33 AM

@FayFen Hi, thanks, I'm new to Scripts so can you tell me what i'm doing wrong

added Script to C:\Program Files\VEGAS\VEGAS Pro 20.0\Script Menu

It shows in VP20 but when applied i get this ?

Musicvid wrote on 10/6/2022, 10:43 AM

You can import marker points into Edit Details (I used Excel), and then split at markers; it goes fast.

https://www.vegascreativesoftware.info/us/forum/senior-moment-insert-markers-at-scene-cuts--117058/#ca729083

 

FayFen wrote on 10/6/2022, 11:57 AM

@FayFen Hi, thanks, I'm new to Scripts so can you tell me what i'm doing wrong

added Script to C:\Program Files\VEGAS\VEGAS Pro 20.0\Script Menu

It shows in VP20 but when applied i get this ?

I don't know, the script looks just as I have. I even cleared few spaces and still it works fine in my VP19.

Former user wrote on 10/6/2022, 2:19 PM

@FayFen Thanks, I copied one of the existing .cs folders, replaced the contents with your script & renamed it,

maybe I'm using it wrong, I added a clip to the timeline, selected/highlighted it, went to Tools - Scripting - SplitEvents.js

PS, same result in VP19. 🤔

jetdv wrote on 10/6/2022, 3:36 PM

The script, as posted, is missing the necessary carriage returns and the spacing is off. Try this instead:
 

/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/

import ScriptPortal.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;

//time intervals for split events.
var Interval = "00:10:00";
try
{
    var IncTime : Timecode = new Timecode(Interval);// step through all selected video events:
    for (var track in Vegas.Project.Tracks) {
        for (var evnt in track.Events) {
            if (!evnt.Selected || evnt.MediaType != MediaType.Video)
                continue;
            evnt.Split(IncTime);
        }
    }
}
catch (errorMsg)
{
    MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

 

Former user wrote on 10/6/2022, 4:12 PM

@ Thankyou, that worked, I had to delete the AppData - Local - VP - VP20. it split it into 10secs - 300frames, I'm guessing that is the ( Interval = "00:10:00"; ) in the script,

If I want to change the name do i have to also change the name at the top of the script, eg. SplitEvents 10secs.

as I'd like to maybe create a few of different split time lengths, ?

Also is there just one file in AppData that i can delete instead of deleting everything when i want this to reload?

Thanks.

(I'm going to have a play with it anyway 🤸‍♂️🤷‍♂️😂)

---------

PS. yep I changed the name in the script & the file name & it sill works, no need to clear AppData for that 👍

-----------

Cool, I added a couple more, don't know if it was necessary but i only deleted the plugin_manager_cache.bin & svfx_plugin_cache.bin from AppData,

Boris Particle Illusion - Custom Shapes use an Image Sequence, the images added to the VP timeline for that sequence need to be 1 frame long, when I add jpegs to make a sequence I have to go into preferences & change the New still image length to 1 frame. Now with this I can chop up a video & select a few of the frames to make a sequence 👍👍

jetdv wrote on 10/6/2022, 4:25 PM

Just change the file name. No need to change any names in the script - just the new lengths you want to use.

Not sure why you needed to do anything in AppData...

Former user wrote on 10/6/2022, 5:36 PM

@jetdv 👍 I just did the AppData thing each time i created one just for the sake of it, because when I added your script the script in Vegas didn't give me a warning msg but it didn't do anything to the event, clearing AppData fixed that & the script split the event, If I create another I'll not do anything in AppData 👍

debojitacharjee wrote on 10/7/2022, 12:23 AM

You can write a script that will cut an event into whatever pieces you want.

I don't know about the script because I am familiar with it. This video shows how to use script for events but doesn't explain about the script. Moreover, the script works only on the markers but I want an automated process to slice a clip (of any length) in equal parts of 10 seconds duration.

debojitacharjee wrote on 10/7/2022, 12:35 AM

As I'm in script mode today, I found a script just for that

/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/import ScriptPortal.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;//time intervals for split events.var Interval = "00:10:00";
try
{var IncTime : Timecode = new Timecode(Interval);// step through all selected video events:
for (var track in Vegas.Project.Tracks) {
for (var evnt in track.Events) {
if (!evnt.Selected || evnt.MediaType != MediaType.Video) continue;evnt.Split(IncTime);
}
}}catch (errorMsg)
{
MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

Copy that and save as SplitEvents.js file in your vegas script menu folder

Thanks for the script but you didn't exlain much about the syntax of the script. I would also like to know how can I modify the code to change the slice duration (i.e. from 10s to 12s)? After running this script on VP16 I got 0x80131600 error.

debojitacharjee wrote on 10/7/2022, 12:39 AM

You can import marker points into Edit Details (I used Excel), and then split at markers; it goes fast.

https://www.vegascreativesoftware.info/us/forum/senior-moment-insert-markers-at-scene-cuts--117058/#ca729083

 

But how do I set the markers at 10 seconds intervals automatically?

debojitacharjee wrote on 10/7/2022, 12:45 AM

The script, as posted, is missing the necessary carriage returns and the spacing is off. Try this instead:
 

/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/

import ScriptPortal.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;

//time intervals for split events.
var Interval = "00:10:00";
try
{
    var IncTime : Timecode = new Timecode(Interval);// step through all selected video events:
    for (var track in Vegas.Project.Tracks) {
        for (var evnt in track.Events) {
            if (!evnt.Selected || evnt.MediaType != MediaType.Video)
                continue;
            evnt.Split(IncTime);
        }
    }
}
catch (errorMsg)
{
    MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

 

I rand the script but nothing happened. an you show it ith a screen video recording?

You can import marker points into Edit Details (I used Excel), and then split at markers; it goes fast.

https://www.vegascreativesoftware.info/us/forum/senior-moment-insert-markers-at-scene-cuts--117058/#ca729083

 

But how do I set the markers at 10 seconds intervals automatically?

FayFen wrote on 10/7/2022, 9:02 AM

The script, as posted, is missing the necessary carriage returns and the spacing is off. Try this instead:
 

/**
* Program: SplitEvents.js
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip
*
* Date: August 24, 2003
**/

import ScriptPortal.Vegas;
import System.Windows.Forms;
import Microsoft.Win32;

//time intervals for split events.
var Interval = "00:10:00";
try
{
    var IncTime : Timecode = new Timecode(Interval);// step through all selected video events:
    for (var track in Vegas.Project.Tracks) {
        for (var evnt in track.Events) {
            if (!evnt.Selected || evnt.MediaType != MediaType.Video)
                continue;
            evnt.Split(IncTime);
        }
    }
}
catch (errorMsg)
{
    MessageBox.Show(errorMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}

 

I'll admit that I have 0 knowledge in the script syntax but this is what I see in notepad and it works just fine on video track.

jetdv wrote on 10/7/2022, 9:19 AM

@debojitacharjee, the tutorial I pointed to shows how to split events at markers. But, it shows how to SPLIT EVENTS. You would need to modify the code to split at the points you wanted it split. And the tutorial gives a full explanation as to what it is doing. Yes, I know it does not "split at 10 seconds" but instead "splits at markers" but does show how the split process works from a script.

The other script listed in this post will do what you were asking. It will split an event into 10 second segments. For it to work, please use the version I posted that has the proper carriage returns. Just copy and paste it into notepad and then save it as SplitEvents.js. You can save it anywhere you want and run it by going to Tools - Scripting - Run Script and then choosing that file. Or you can save in in My Documents\Vegas Script Menu and it will be available under Tools - Scripting - SplitEvents. Then select the event you want cut into segments and run the script.

If you go to the older tutorials on my page, you will see much information you may have been missing.

jetdv wrote on 10/7/2022, 9:35 AM

Also note the script above was posted in JScript where all the tutorials on my site are in C#. But they can be converted if desired.

Here's the same script converted to C# so, in this case, the file name would be SplitEvent.cs
 

/**
* Program: SplitEvents.cs
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip, converted to C# by Edward Troxel
*
* Date: August 24, 2003, converted to C# Oct 7, 2022
**/

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            // Set the split size here - this is 10 seconds
            Timecode Interval = new Timecode("00:00:10:00");

            try
            {
                Timecode IncTime = Interval;
                
                // step through all tracks in the project:
                foreach (Track track in myVegas.Project.Tracks)
                {
                    // step through all events on the track
                    foreach (TrackEvent evnt in track.Events)
                    {
                        // Skip the event if it is not selected or it is not a video event
                        if (!evnt.Selected || evnt.MediaType != MediaType.Video)
                        {
                            continue;
                        }
                        // Split the event
                        evnt.Split(IncTime);
                    }
                }
            }
            catch (Exception errorMsg)
            {
                MessageBox.Show(errorMsg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}

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

 

Former user wrote on 10/7/2022, 9:36 AM

I would also like to know how can I modify the code to change the slice duration (i.e. from 10s to 12s)?

@debojitacharjee Change this number to 00:12:00,

debojitacharjee wrote on 10/8/2022, 12:53 AM

@debojitacharjee, the tutorial I pointed to shows how to split events at markers. But, it shows how to SPLIT EVENTS. You would need to modify the code to split at the points you wanted it split. And the tutorial gives a full explanation as to what it is doing. Yes, I know it does not "split at 10 seconds" but instead "splits at markers" but does show how the split process works from a script.

The other script listed in this post will do what you were asking. It will split an event into 10 second segments. For it to work, please use the version I posted that has the proper carriage returns. Just copy and paste it into notepad and then save it as SplitEvents.js. You can save it anywhere you want and run it by going to Tools - Scripting - Run Script and then choosing that file. Or you can save in in My Documents\Vegas Script Menu and it will be available under Tools - Scripting - SplitEvents. Then select the event you want cut into segments and run the script.

If you go to the older tutorials on my page, you will see much information you may have been missing.

I ran the script but nothing happened. Does it work without the markers? This script is for Sony VP or also works with Magix? I am using VP16 only.

debojitacharjee wrote on 10/8/2022, 12:58 AM

Also note the script above was posted in JScript where all the tutorials on my site are in C#. But they can be converted if desired.

Here's the same script converted to C# so, in this case, the file name would be SplitEvent.cs
 

/**
* Program: SplitEvents.cs
* Description: This script will split selected event into pieces for specified seconds
* Author: Philip, converted to C# by Edward Troxel
*
* Date: August 24, 2003, converted to C# Oct 7, 2022
**/

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

namespace Test_Script
{
    public class Class1
    {
        public Vegas myVegas;

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

            // Set the split size here - this is 10 seconds
            Timecode Interval = new Timecode("00:00:10:00");

            try
            {
                Timecode IncTime = Interval;
                
                // step through all tracks in the project:
                foreach (Track track in myVegas.Project.Tracks)
                {
                    // step through all events on the track
                    foreach (TrackEvent evnt in track.Events)
                    {
                        // Skip the event if it is not selected or it is not a video event
                        if (!evnt.Selected || evnt.MediaType != MediaType.Video)
                        {
                            continue;
                        }
                        // Split the event
                        evnt.Split(IncTime);
                    }
                }
            }
            catch (Exception errorMsg)
            {
                MessageBox.Show(errorMsg.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
    }
}

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

 

VP16 supports Java or #C script?

jetdv wrote on 10/8/2022, 10:33 AM

Yes, VP16 supports both JScript and C# (and more). Either version of the script will work, you just need to make sure they are named properly. And, yes, it will work without markers. But the event you want cut:

  1. Must be a video event
  2. Must be selected.
rraud wrote on 10/8/2022, 11:16 AM

I can confirm the script works in VP-16, providing the rules @jetdv stated are followed.

debojitacharjee wrote on 10/9/2022, 1:26 AM

Yes, VP16 supports both JScript and C# (and more). Either version of the script will work, you just need to make sure they are named properly. And, yes, it will work without markers. But the event you want cut:

  1. Must be a video event
  2. Must be selected.

Thanks! it works.