VEGASPython Tutorial

Chapter 1 Introduction to VEGASPython Scripting


VEGAS is one of the few video editing applications that provide an open interface to add functionality to the application. The VEGAS scripting interface is based on a programming platform from Microsoft called .NET. The .NET framework was launched in 2000 and has since become a popular platform for object-oriented programming. Included in the .NET framework are a vast array of libraries and classes including the Windows Forms and Windows Presentation Foundation (WPF) graphical user interfaces, as well as libraries for communicating across networks, working with databases, creating web applications. The traditional languages for writing .NET programs are Visual Basic.NET, C#, and JScript. Therefore the standard VEGAS scripting languages are Basic.NET, C# and JScript.

In the video editing area, and not only there, another programming language has become popular: Python.

Python is a programming language with a clean syntax that is easy to learn. It is around since 1990. And yes, the name Python comes from the famous British Comedian Group Monty Python.

Python is used in many application domains including: Web and Internet Development,Scientific apps,Desktop apps, education, general software applications and Video Scripting.

You can find more details about Python on the official website: For historical reasons there are two versions of Python language avilable: Python 2.x and Python 3.x. Unfortunately Python 3.x includes a lot of incvompatible changes to the Python language so that version 2.x has still to be maintained, as a lot of solutions are based on this version VEGASPython is also based on Python 2.x.

PythonNet: Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.

Several different Python implementations are available CPython, JPython etc. The orginal version is called CPython as it is written in the programming language „C“.

VEGASPython is based on a PythonNet. PythonNet is an extension of CPython and therefore compatible with all Cpython extension modules.

An older version of VEGASPythion was based on IronPython. IronPython is an open source implementation of Python for .NET. The development had been started by Microsoft but is now given to an open community that is still active and provides regularly new updated versions of IRONPython. If you want to know more about IRONPython you can get more information on the official website good and detailed information about IRONPython can be found in the book „IronPython in Action“ by Michael J. Foord and Christian Muirhead. Here is the link to the homepage: The main problem of IRONPython is the incompatibility with several standard Python moduels like openCV and NumPy. Especially openCV is interesting for Video editing.

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.

Hello World

Nearly all programming tutorials start with the so called „Hello World“ program. This is a very simple program that provide the text „Hello World“ as an output.

This sounds simple, but with this simple program you learn how to use your programming environment and how to run a program.

So let´s start with creating a „Hello World“ script in VEGASPython.

Installation of VEGASPython

I assume that you have installed VEGASPython accoriding to the installation description - VEGASPython Download and Installation

the interactive VEGASPython Window

We will start using the interactive VEGASPython window it allows a very fast and easy Python script creation and execution.

You open the window in VEGAS via „View - Extensions - VEGASPython Interactive Window“

This opens the interactive VEGASPython Window:

The interactive VEGASPython Window consists of two textboxes. The upper textbox is the Input textbox, where you can enter Python commands and scripts. The lower part is the Output textbox that shows the results of the Python Command execution.

After the first start of the window the output shows that the script has been executed. This script is located in the same folder as the VEGASPython.dll and includes some inital Python commands that make your life easier. Please feel free to add additional commands or function declarations that you would like to have at hand during your work.

The VEGASPython window can float over the VEGAS UI or can be docked into the user interface like all other VEGAS windows.

The program

In VEGASPython the standard „Hello World“ script is very easy:


print ("Hello World")

in the input textbox and click on „Execute VEGASPython Script“ in the Menu. The text „Hello World“ will be printed into the Output textbox.

If you did something wrong then you will see an error message in the Output textbox.

When you mastered this script then you have already mastered a big step to be able to write VEGASPython scripts.

Introduction to the Python Language

It is not the intention of this tutorial to provide a complete Python tutorial. I will only show you the items you need to know to be able to create or modify VEGASPython scripts. VEGASPython is based on Python 3.x. Therefore the Python 3 syntax has to be used.


In the Hello World script we saw already two important concepts of Python: functions and strings.

print is a function that is build into Python and print text into the output textbox.

A lot of functions are already included in Python. But you can also define your own functions and you import functions from so called libraries. We will cover this later.

Functions can have parameters. In the example, you provided the print function with the parameter „Hello World“. This tells the print function to print this parameter value into the output textbox.

The parameter „Hello World“ has the datatype string.

A string can be enclosed in single quotes ('…') or double quotes („…“) . If you need to enter single or double quotes in the text you can use \ to escape quotes.

Examples: 'doesn\'t' use \' to escape the single quote

or use the other quote type



In addition to function you also need variables to store information. A variable has a name, a datatype and a value.

Variables can be of several data types. Python supports integers (numbers), floating point numbers, booleans (true or false) and strings (text).

Python will determine the datatype of a variable based on the value you assign to the variable during the execution of the script.

  • If you create a variable x, x = 3, then Python assumes its an integer.
  • If you assign x = 1.5 then Python knows its not an integer but floating point number.

Please try this:

numberVariable = 5
print (numberVariable)
floatVariable = 0.5
print (floatVariable)
stringVariable = "Number 5"
print (stringVariable)

This is a big difference to most other programming languages where you have to define the datatype of all variables before you can use them.

= Variable naming = A variable name must begin with a letter (upper or lower case) or an underscore. Variables cannot start with a number and are case sensitive. The variables x and X are different variables.

By convention variables are often camel cased, meaning the first letter is small and the next words are all capital.

Some example variables that use camel casing

numberSelectedEvents = 5 currentTime = „00:00:04:00“

This is easier to read than having one long variable (numberselectedevents) or shorter than using underscores (number_selected_events). It is up to you how you name your variables. There are no strict rules.

Some hints:

  • use speaking names for the variables (use „numberSelectedEvents“ and not „n1“)
  • you can define as many variables you like. There is absolutely no need to reuse variables for different purposes (e.g. the variable „numberEvents“ is once used to store the number of all events in a project, afterwards to store the number of events in a track and then the number of selected events - use three different variables for this)

Access to VEGAS

Already with the few items we have seen of Python in this chapter we can already access the VEGAS application.

To interface with the VEGAS application and to get access to the application internal items like tracks, events and effects VEGASPython use a special variable:


pyVEGAS has the datatype „Vegas“. „Vegas“ is a predefined datatype from the „Vegas Pro Scripting API“. We will discuss the „Vegas Pro Scripting API“ in a later chapter.

For now you only have to know that the datatype „Vegas“ has a property „Version“. Version is of type string.

To access the property „Version“, you only have to append it to the variable pyVEGAS separated by „.“ So pyVEGAS.Version give us a string with the version of the currently running Vegas application. So let´s print the Vegas version. Please enter the following code into the input Textbox and execute it.

print (pyVEGAS.Version)

This command prints the current version of VEGAS into the Output textbox: Version 16.0 (Build 261).


In this chapter we learned how to write a simple „Hello World“ script and how to access a VEGAS property.

In the next chapter we will discuss how to access tracks and events.

Andere Sprachen
QR-Code en:chapter1 (erstellt für aktuelle Seite)