-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resize Generated Media.cs
72 lines (65 loc) · 2.03 KB
/
Resize Generated Media.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* This script resizes all generated media to match the size and pixel
* aspect ratio of the project. The script will operate on the
* selected video event or, if none are selected, it will operate on
* all video events.
*
* Revision Date: March 26, 2010.
**/
using System;
using System.Drawing;
using System.Collections.Generic;
using ScriptPortal.Vegas;
public class EntryPoint
{
public void FromVegas(Vegas vegas)
{
Size projectSize = new Size(vegas.Project.Video.Width, vegas.Project.Video.Height);
double projectAspect = vegas.Project.Video.PixelAspectRatio;
List<VideoEvent> events = new List<VideoEvent>();
AddSelectedVideoEvents(vegas, events);
if (0 == events.Count)
{
AddAllVideoEvents(vegas, events);
}
foreach (VideoEvent videoEvent in events)
{
Take take = videoEvent.ActiveTake;
if (null == take) continue;
VideoStream videoStream = take.MediaStream as VideoStream;
if (null == videoStream) continue;
if (!videoStream.Parent.IsGenerated()) continue;
videoStream.Size = projectSize;
videoStream.PixelAspectRatio = projectAspect;
}
}
void AddSelectedVideoEvents(Vegas vegas, List<VideoEvent> events)
{
foreach (Track track in vegas.Project.Tracks)
{
if (track.IsVideo())
{
foreach (VideoEvent videoEvent in track.Events)
{
if (videoEvent.Selected)
{
events.Add(videoEvent);
}
}
}
}
}
void AddAllVideoEvents(Vegas vegas, List<VideoEvent> events)
{
foreach (Track track in vegas.Project.Tracks)
{
if (track.IsVideo())
{
foreach (VideoEvent videoEvent in track.Events)
{
events.Add(videoEvent);
}
}
}
}
}