Relative Duration of Selected Events.

RRA wrote on 8/30/2009, 11:28 AM
Hi,

Does anybody know where to download script :

... how to change relative duration of selected events (events could have different duration times) to specified (open dialog window) value ?

The aim of script is to change duration of all selected events with simultanous changing velocity but WITHOUT looping or repeating last frame (as a still picture) at the end of the event.

It is equivalent of CTRL+MOUSE_DRAG_RIGH (stretch event).

In VASTT Ultimate S or in Menu/View/Edit Details i can rescale group of events but always as a looped event or as a expanded by last frame repeating.

Best regards,

Comments

jetdv wrote on 8/31/2009, 6:34 AM
So... You're basically just wanting to change the playback rate on selected clips and have the lengths automatically adjust to the new playback rate? Are all the playback rates to be the same change?

The Playback Rate tool in Excalibur will change the playback rate on all selected events to the new playback rate and adjust their lengths to match the new playback rate. So, for example, if you set the new playback rate to .5, all selected events would play at half speed and their length would be doubled.
RRA wrote on 8/31/2009, 11:53 AM
HI,

No, my target is quite opposite : for example I have about 50 tracks and only one event located on each track (events are different movies (different size, format) and have different duration, usually very short about 10 seconds). I'm going to make selection and fix duration of all events as 30 seconds (I don't care about changing velocity as a consequence). In next step I will (with help of Ultimate S) create video wall in one command. I need to present all events without looping. All events have to start and stop in exactly the same time - pace of playback is not a target, is disregarded.

Up till now my workflow is like this :

1) select event on track 1
2) stretch event to 30 s
3) select event on track 2
4) stretch event to 30 s

etc....

I'm bored near 30 track and almost dead on 50.

Best regards,

RRA
jetdv wrote on 9/1/2009, 6:50 AM
So, the script would need to calculate the playback rate necessary in order to stretch it out to the 30 second length (in this case). Basically, resize to the set length and then adjust the playback rate (or velocity envelope?) so that it ends in the same place it previously ended?
RRA wrote on 9/1/2009, 9:58 AM
Hi,

I was reckoned that it will be possible to stretch event without adjusting relative playback rate - this metod seems to be risky. I know that issues conected with rescalling on the timeline are always difficult and can lead to mistakes from rounding of digits. But I don't know anything about scripting in Vegas. Maybe there is no other method. My first impression was that it would be possible to use "macro sequention" (select, use Vegas stretch command, select, use Vegas stretch command...) like it's possible in Word for example.

From Your post I can recognize that scripting is going deeper then macros and CTRL+MOUSE_DRAG_RIGHT command is not directly accesible. If situation is like this, I can understand way this apparently easy script is not ubiquitous (because recalculating playback pace consist of dividing and multiplaying operation and result will have to be rounded).

Best regards,

jetdv wrote on 9/1/2009, 12:10 PM
Perhaps here's your confusion:

CTRL-Mouse Drag Right = adjust the playback rate.

If you resize a clip while holding down the CTRL key, that's a shortcut method to changing the playback rate. Right-click the event, go into the properties, and look at the playback rate both before and after you CTRL resize and you'll see that the value has changed.
Rosebud wrote on 9/1/2009, 12:30 PM
It is equivalent of CTRL+MOUSE_DRAG_RIGH (stretch event).

Select all your events and press ’G’ to group them
You can now stretch all the events at the same time.
RRA wrote on 9/1/2009, 12:40 PM
Hi,

From Vegas Help :

Stretch (compress) the media in the event while trimming =

= Ctrl+drag edge of event

Lenght of the event is input parameter of command and playback rate change is consequence of changing length.

I have checked Excalibur in meantime and probably it is not suitable to my task. Playback change ratio is input parameter.

BEFORE : (events with various size on timeline)

[...................]
[.......]
[...............]
[............................]
[..................]
[.......]
etc.

AFTER : (one dot means 1s)
[..............................]
[..............................]
[..............................]
[..............................]
[..............................]
etc.

Regards,
Grazie wrote on 9/4/2009, 2:33 AM
Maybe this will do it for you. It is NOT a Script solution. PLUS you have indicated that the content of the media isn't "time" critical?

Approach this, the other way around. Leave the Shortest as the Datum, by deleting the longest to the END of the shortest.

Do a WHOLE Project multi track "Loop Region" selection, from the END of the longest backwards to the END of the shortest. You should now have all the "ragged" ends covered. Hit Delete. This will remove all the ends. Save this as a TEST1a.veg . Open a NEW instance of Vegas and import the Test1a.veg and place on Timeline. Now you can treat the imported Test1a.veg as any other piece of Media. You can stretch it, Loop it and IF you want to re-edit it you can do a right click and edit Test1a.veg further.

I do like Nested Veggies.

Grazie
RRA wrote on 9/4/2009, 4:32 AM
Hi,

I'm not sure whether I have understood Your idea properly : probably You suggest to cut uneven ends of events. I can't use that solution, sometimes there are very short files in the same set with long files. I have to protect velocity of the longest and stretch smaller.

My timeline BEFORE looks like this :

[...................]
[.......]
[...............]
[........................] this is the biggest event but time is defined independently
[..................]
[.......]
etc.

I know only tools which can offer solution AFTER like this :

[...................^...........]
[.......^.......................]
[...............^...............]
[..........................^....]
[..................^............]
[.......^.......................]
etc.

(sign ^ is indicator of looping or last frame repeating, it's unwanted)

BUT I NEED TO ACHIEVE THIS :

[..............................] there is 30 dots in each, it represent 30 seconds
[..............................]
[..............................]
[..............................]
[..............................]
etc.

Regards,
jetdv wrote on 9/4/2009, 6:44 AM
Short answer: It CAN be done via scripting.

However, I know of no script that currently does this so it would have to be written.

In Excalibur, I change the playback rate and adjust the length of the event to match the new playback rate. However, this script will need to go the other way - figure out what the new playback rate needs to be after adjusting the event to the new length. But it *CAN* be done.

Here's a really old simple script that will adjust the playback rate of all selected events. It won't do the specific task you're looking for but will give the code basics for adjusting the playback rate:

//PlayBackRate.js
import Sony.Vegas;

for (var currentTrack : Track in Vegas.Project.Tracks) {
if (currentTrack.IsVideo() == true) {
for (var currentEvent : TrackEvent in currentTrack.Events) {
if (currentEvent.Selected == true) {
currentEvent.PlaybackRate = .5;
}
}
}
}


Your routine would need to see how long the event is, know how long it NEEDS to be, adjust the event to the new length, and calculate the proper playback rate to apply.
Teetow wrote on 9/4/2009, 1:39 PM
That sounds fairly trivial, unless I'm not completely confused about what you're trying to do. This function basically asks "how slow do I have to play back my event to make it end the same time as the longest event in the selection?"

Please keep in mind that you can only slow down / speed up events by a factor of four. After that, you have to do offline processing.

pseudocode:


LongestEvent = FindLongestEvent(ListOfEvents); // trivial function to write
foreach (event in ListOfEvents)
{
event.PlaybackRate = event.Length / LongestEvent.Length;
event.Length = LongestEvent.Length;
}
RRA wrote on 9/5/2009, 6:03 AM
Hi,

Yes, Thank You - this is very important step. Now I can use Your function to equalize lenght of all events, then select all, group and use CTRL+DRAG_MOUSE_RIGHT in order to achieve assigned duration.

Does it work on all selected events ? I'm not familiar with scripting at all : is it ready to add to Vegas scriptin menu ?

Best regards,
jetdv wrote on 9/5/2009, 10:02 AM
There is one other catch when using the playback rate. The smallest allowed value is .25 (or 1/4th speed). So if you had a 2 second clip to put into the 30 second hole, the division would come out to 2/30 or .0667 which is an illegal value. It would work fine with a velocity envelope, though.

RRA, the code segment I gave is a complete .js script that will run. The other code segment is not a runable script - just a segment that would be placed in a larger script.

Here's a full script that will do what you want. Copy the text, paste it into Notepad, and then save it as "MatchLongestClip.cs". Select the clips to be adjusted and then run this script. If the clip is too short, it will NOT adjust the playback rate.

To make the script more powerful, if the playback rate was less than .25, it could be modified to add a Velocity Envelope instead. This would allow you to also use very short clips and match them as well.

using Sony.Vegas;

public class EntryPoint
{
Vegas myVegas;

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

//Find the largest selected video clip
Timecode LongestClip = new Timecode(0);
foreach (Track track in myVegas.Project.Tracks)
{
if (track.IsVideo())
{
foreach (TrackEvent evnt in track.Events)
{
if (evnt.Selected)
{
if (evnt.Length > LongestClip)
LongestClip = evnt.Length;
}
}
}
}

//Now adjust the shorter video events
foreach (Track track in myVegas.Project.Tracks)
{
if (track.IsVideo())
{
foreach (TrackEvent evnt in track.Events)
{
if (evnt.Selected)
{
double NewPBRate = evnt.Length.ToMilliseconds() / LongestClip.ToMilliseconds();
if (NewPBRate >= .25 && NewPBRate <= 4)
evnt.PlaybackRate = NewPBRate;
evnt.Length = LongestClip;
}
}
}
}

}

}



Note: this is the quick and dirty version with NO optimizations applied. But it will work for the task you've specified.
RRA wrote on 9/7/2009, 5:30 AM
Hi,

Thank You very much - I have installed script and it works as You said.

Now I have finnally understood, way I can't stretch group of events to very big extent : because there is a condition/limitation, which You have mentioned, do not to overcome 0.25 playbeck rate for shortest event in group.

Best regards,
jetdv wrote on 9/7/2009, 6:55 AM
The script could be modified so that it uses the Velocity Envelope in cases where the speed change was less than .25. Or it could just use the Velocity Envelope all the time. But all the basics are now here. But, yes, if the shortest clip(s) are less than 1/4 the length of the longest event, the playback rate adjustment cannot properly adjust for the full change.