Please excuse any typing errors during the translation from our German vMix WIKI page.
Scripting only works with the 4K or PRO version.
Some examples and tricks for the scripts in this post are from “doggy's” SCRIPTING FOR DUMMIES SCRIPTING FOR DUMMIES and other posts from the vMix forum.
Scripting is possible within vMix using the built-in editor or as an external command via browser. The collection of examples is incomplete. In the appendix it has a listing from a few of the currently known API commands. vMix Scripting supports Web scripting and VB.NET when writing your script. All variables are local, from version 24 there are dynamic variables and dynamic inputs, which could be called public variables. But their use is a bit cryptic. But you can easily use text fields of an unused title input as pubic variables. The input can be either the filename of the title (case sensitive) or the input number.
In the beginning, the vMix Script Builder (an external utility) is an indispensable help. It creates scripts with the correct syntax, selection via pulldown menus.
vMix Script Builder The Universal Title Controller is by the same author.
Link with permission from the author Richard “Raugert”
Super online tool, Shows the correct syntax for every possible command to control vMix.
THE UNOFFICIAL vMix API Reference
Link with permission from the author Nick Roberts.
Syntax to:
Online tool, shows the correct syntax to control vMix via HTTP commands
online HTTP vMix commands Builder
Link with permission from the author Jeff “Dist” Martin. https://dist.dev/
Die Beschreibung auf der vMix Seite ist etwas dürftig, trotzdem lohnt sich immer ein Blick dorthin.
vMix API Website
Eine Liste der vorhandenen API Funktionen gibt es auf der Webseite von vMix.
alle API Funktionen Version 24 Übersicht
The script editor can be reached via “Settings”, “Scripting” Add
AVOID SPACE IN SCRIPTNAMES
A script can be called via a shortcut.
there are 4 different ways to write a script. In the end the variants all do the same. Normally the simplest variant is sufficient in vMix Editor. (WEB)
–VB.net can handle variables, WEB cannot.
–API corresponds to VB net
–WEB without variables, short and simple, sufficient for most internal scripts.
–HTTP sends the API command via browser or external software.
Both AudioBusOFF and audiobussoff work.
ACHTUNG: Titles and text fields are case sensitive:
Title 0- The Classic Blue.gtzip is exactly what the title is called. The script does not work if the upper/lower case is changed.
This example writes “Some Text” into a specific text field of a specific title.
Instead of the title name, the input number can also be specified, instead of the text field, its index number.
WEB
Function=SetText&Input=1&SelectedIndex=0&Value=Some Text
VB.NET API
API.Function("SetText",Input:="1",SelectedName:="Headline.Text",Value:="Some Text")
VB.NET
Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "Some Text"
HTTP get
http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Some Text
This will return all available data from the API (Application Programming Interface) of vMix as XML. (Put the following command line in your browser, vmix has to run on the same machine)
http://127.0.0.1:8088/api/?
Be careful when using web addresses with symbols like , # etc., as these must be correctly “encoded” to work as a url value. This is not only the case with vMix, but with all web-based APIs. This is a handy tool that can be used to code the values correctly: URL Decoder/Encoder
Enter only the text you want to set as a value, not the whole url. This would make
Excel/CSV,Sheet1,5
become the following
Excel%2FCSV%2CSheet1%2C5
And the whole URL again would be:
http://localhost:8088/API/?Function=DataSourceSelectRow&Value=Excel%2FCSV%2CSheet1%2C5
This example uses the supplied title NewsHD and writes Hello World in the field Headline
Input.Find("NewsHD.xaml").Text("Headline") = "Hello World!"
or to put it another way:
dim i = Input.Find("NewsHD.xaml") i.Text("Headline") = "Hello World!"
route INPUT 4 Video to OUTPUT
Function=Activeinput&Input=4 or Function=Cutdirect&Input=4 or http://127.0.0.1:8088/API/?Function=Cutdirect&Input=4 or API.Function("Cutdirect",4,)
route INPUT 3 Video to Preview
Function=Previewinput&Input=4
route INPUT 1 Video to OUTPUT2 routen
Function=SetOutput2&Input=1&Value=1
Route input with a specific name onto the OUTPUT
Input.Find("YourInput").Function("Cut")
Cut cuts INPUT4 to the OUTPUT and changes the previous input to Preview, Cudirect leaves the preselected Preview input.
API.Function("Cut",4,)
or
API.Function("Cutdirect",4,)
API.Function("PreviewInput",4,)
Mix 0 = PGM
MIX 1-3 = Input Mixes, only available on the 4K/Pro versions.
-1 = PREVIEW
fade Preview to PGM
API.Function("Fade",Input:=-1,Mix:=1)
cut Input 2 to PGM
API.Function("Fade",Input:=2,Mix:=1)
All these functions create a new input
Title Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=Xaml|C:\VMIX\Name.gtzip
Video Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=Video|c:\path\to\video.avi
Image Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=Image|c:\path\to\image.jpg
Picture Folder Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=Photos|c:\path\to\folder
Video Playlist (m3u)Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=VideoList|c:\path\to\playlist.m3u
Audio file Input from a specific directory
http://127.0.0.1:8088/API/?Function=AddInput&Value=AudioFile|c:\path\to\audio.wav
Powerpoint Input Input from a specific directory
(From my experience, only slides without videos or audios or media files are not played)
http://127.0.0.1:8088/API/?Function=AddInput&Value=PowerPoint|c:\path\to\powerpoint.pptx
Color Input (RGB Farbwert)
http://127.0.0.1:8088/API/?Function=AddInput&Value=Colour|%23FF5733
this allows two inputs to be swapped back and forth, e.g. via the space bar. The input name of the first input serves as the query
if word = "DeckLink Duo (1) 1" then API.Function("MoveInput",Input:="DeckLink Duo (1) 1" , Value:=2) else API.Function("MoveInput",Input:="DeckLink Duo (1) 1" , Value:=1) end if
Switch on Audio bus of source 1 (green loudspeaker)
Function=AudioON&Input=1 or API.Function("AudioON",1,)
Route audio bus of source 1 to audio output D
Function=AudioBusON&Input=1&Value=D oder API.Function("AudioBusOff",2,"A")
Route audio bus of source 2 to audio output master
Function=AudioBusON&Input=2&Value=M
Route audio bus of source 1 away from the master
Function=AudioBusOFF&Input=1&Value=Master
Route audio bus of source 3 away from the D
Function=AudioBusOFF&Input=1&Value=D
Switch off audio follow video from input 1
Function=AudioAutoOff&Input=1
Dim doc As New XmlDocument() doc.LoadXml(API.Xml) Dim root As XmlNode = doc.DocumentElement Dim i as Integer Dim xel As XmlElement Dim node As XmlNode = root.SelectSingleNode ("/vmix/active") ‘look for node Dim inputNumber as Integer = node.InnerXml 'shows active input ‘how many inputs are active Dim vmixinputs as Integer 'inputs in total For Each xel In Doc.SelectNodes("vmix") vmixinputs = (xel.SelectNodes("inputs/input").Count) Next xel for i = 1 to vmixinputs API.Function("AudioBusOff", i, "D") Next
This script reads the current title of a playlist and writes it formatted into a field of a title.
In this example I use the title “ Title 33- On the shelf- Peach.gtzip ” contained in vMix and write the text into the field “Headline.Text”. My list input is Input2. Please adapt this (title, field and list input number) for your project.
I use a list of MP3 audio files. These are named as follows:
Anni Piper - Two's Company - 01 - Blues Before Sunrise.mp3
Anni Piper - Two's Company - 02 - Live To Play.mp3
Anni Piper - Two's Company - 03 - Man's Woman.mp3
The goal is to extract a usable name from this string.
The finished script looks like this:
'script playing now do dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) dim word as string = x.SelectSingleNode("//input[@number=[h]'2'[/h]]/@title").Value word = word.remove(word.Length - 4) dim wordArr as String() = word.Split("-") Dim result0 as String = wordArr(0) Dim result1 as String = wordArr(1) Dim result2 as String = wordArr(2) Dim result3 as String = wordArr(3) Dim result4 as String = wordArr(4) dim fullname as string = result1 + " " + result2 + " " + result4 API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result1) sleep(1000) API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result2) sleep(1000) API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=result4) sleep(1000) API.Function("SetText",Input:="Title 33- On the shelf- Peach.gtzip",SelectedName:="Headline.Text",Value:=fullname) sleep(1000) loop
The volume value of an input read out via API cannot be set 1:1 to a fader volume of an output, the value must be converted.
' Create the XML document to parse dim x as new system.xml.xmldocument ' Load the API into the XML document. For a visual, see http://127.0.0.1:8088/api x.loadxml(API.XML()) ' gets the current value of the attributes "Volume" from the input (in this case Input1) dim xmlVolume As Double = x.SelectSingleNode("//input[@number='1']/@volume").Value xmlVolume = xmlVolume / 100 ' Presumably this is actually Amplitude and not Volume. Amplitude is expected to be a normalised (0-1) value in the formula, which is not the case in the XML. dim faderVolume As Integer = cint((xmlVolume ^ 0.25) * 100) ' Formula: Volume = (Amplitude ^ 0.25) * 100 ' now we set the volume of BUS A to the volume of input 1 API.Function("SetBusAVolume",,Value:=faderVolume )
Shows in a title which audio buses are occupied by the inputs. Title here audiochannels.gtzip
The output is not very elegant, the title deletes completely in between, but it shows the possibilities.
do while true ' erase contents in titel Input.Find("audiochannels.gtzip").Text("Text1.Text")="" ‘ how many INPUTS are active? dim doc As New XmlDocument() doc.LoadXml(API.Xml) dim root As XmlNode = doc.DocumentElement dim xel As XmlElement dim node As XmlNode = root.SelectSingleNode ("/vmix/active") ‘look for node Dim vmixinputs as Integer 'inputs insgesamt For Each xel In Doc.SelectNodes("vmix") vmixinputs = (xel.SelectNodes("inputs/input").Count) Next xel ' loop to read out the XML API on audio inputs Dim i as integer dim eingang as string dim text as string dim titel as string for i = 1 to vmixinputs try dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) eingang = (x.SelectSingleNode("/vmix/inputs/input[" & cstr(i) &"]/@audiobusses").InnerText) titel = (x.SelectSingleNode("//input[@number="& cstr(i) + "]").InnerText) console.writeline(cstr(i) & " " & eingang) text = Input.Find("audiochannels.gtzip").Text("Text1.Text") eingang = eingang.padright(25," ") Input.Find("audiochannels.gtzip").Text("Text1.Text")=text + Environment.NewLine + cstr(i)+ " " + eingang + " " + titel Catch ex as Exception console.writeline(cstr(i)+ " does not contain Audio") text = Input.Find("audiochannels.gtzip").Text("Text1.Text") Input.Find("audiochannels.gtzip").Text("Text1.Text")=text + Environment.NewLine + cstr(i) + " does not contain Audio" end try next sleep (200) loop
dim audios as string do while true Dim xml as string = API.XML() Dim x as new system.xml.xmldocument x.load("http://localhost:8088/api") audios= (x.SelectSingleNode("//input[1]/@audiobusses").InnerText) console.writeline(eingang ) If audios= "M,A" 'do this Else if audios= "M,A,B" 'do that else 'do something else end if loop
This script “ducks” an original audio signal when, for example, the translator speaks The script comes from a Russian programmer, there is a video about it on YouTube. https://youtu.be/amrkD2SIdrM
' ---- settings for SIDECHAIN control script ---- dim translateInput as string = "Mice" 'Name of the vMix Input with the Translator dim origInput as string = "Orig PGM" 'Name of vMix Input with the original soundtrack dim volumeStandart as string = "100" 'The volume of the Original Reference when the Translator is silent dim fadeTimeStandart as string = "1200" 'The length of the volume increase when the Interpreter is silent dim volumeSpeaking as string = "60" 'The volume of the Original when the Translator speaks dim fadeTimeSpeaking as string = "200" 'The length of time Original is silenced when the Interpreter speaks dim voicethreshold as string = "0.05" 'Interpreter response threshold, from 0 to 1 (log scale) ' Corresponds to the values (not the length) on the volume slider: 0.5=50%~=-6dB, 0.1=10%~=-20dB... ' The response may not work with a single signal pulse, but works well with a signal like voice or music dim checkingIter as integer = 10 'The number of iterations of checking the interpreter silence before triggering dim checkingIterTime as integer = 200 ' The interval (milliseconds) between the checking iterations (recommended from 100, silent 200) ' Means the length of the check that the translation is silent and can be turned on Orig. = checkingIter * checkingIterTime (millisecs) '---- end of settings---- dim voicemeter as string = "" dim speaking as boolean = false dim silence as boolean = false dim silencechecking as integer = 0 dim muted as boolean = false do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF1").Value) if (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value) > voicemeter voicemeter = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@meterF2").Value) end if muted = (x.SelectSingleNode("//input[@title='"& translateInput &"']/@muted").Value) 'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:=voicemeter) 'console.writeline(voicemeter) if voicemeter > voicethreshold And voicemeter.IndexOfAny("[E]".ToCharArray) = -1 And Not muted if silencechecking >= checkingIter '<> 0 '!= 'console.writeline("Speaking") silencechecking = 0 'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="yellow") 'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Translation speaks! " + voicemeter) Input.Find(origInput).Function("SetVolumeFade", volumeSpeaking + "," + fadeTimeSpeaking) end if 'console.writeline(silencechecking) else if silencechecking < checkingIter silencechecking += 1 end if if silencechecking = checkingIter 'console.writeline("Silence") 'API.Function("SetTextColour",Input:="TextInput",SelectedName:="Timer.Text",Value:="white") 'API.Function("SetText",Input:="TextInput",SelectedName:="Timer.Text" ,Value:="Translation is silent! " + voicemeter) Input.Find(origInput).Function("SetVolumeFade", volumeStandart + "," + fadeTimeStandart) silencechecking = checkingIter + 1 end if 'console.writeline(silencechecking) end if sleep(checkingIterTime) Loop
Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "Text changed"
or
API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="Text changed")
or
http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Text changed")
There go argb values or valid names for a colour (red, blue, black, transparent etc.) argb values and names can be found here https://www.w3schools.com/colors/colors_names.asp
API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="transparent")
Add +=1
Substract -=1
Assign the script to a button.
Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "+=1"
or
API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:=" Headline.Text ",Value:="+=1")
The following is used as the IP address:
-127.0.0.1 if the browser is running on the same computer as vMix.
-the IP of the other vMix computer, in the same network
Changes a (Logo, Foto etc.)
http://127.0.0.1:8088/API/?Function=SetImage&Input=Titel.gtzip"&SelectedName=LOGO.Source&Value=C:\VMIX\ch.png
Sets an image (logo, photo, etc.) to invisible (visible = SetImageVisibleOn)
http://127.0.0.1:8088/API/?Function=SetImage&Input=Titel.gtzip&Image=LOGO.Source&Value=C:\VMIX\ch.png
Changes text in a specific field via browser
http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Text geändert
Changes text colour in a specific field via browser
http://192.168.1.55:8088/api/?Function=SetTextColour&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=red
in which first the active input number is determined, then an action is carried out based on the input number. It runs as a loop, i.e. as long as someone starts the script and does not stop it again.
The code can also be programmed more effectively. But this is then not so clear.
do while true Dim doc As New XmlDocument() doc.LoadXml(API.Xml) Dim root As XmlNode = doc.DocumentElement Dim node As XmlNode = root.SelectSingleNode("/vmix/active") Dim inputNumber as Integer = node.InnerXml If inputNumber = 2 Then Input.Find("whoisonair.gtzip").Text("Text11.Text") = "caller1 onair OUT1" API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg11.Text",Value:="red") Input.Find("whoisonair.gtzip").Text("Text21.Text") = " " Input.Find("whoisonair.gtzip").Text("Text31.Text") = " " Input.Find("whoisonair.gtzip").Text("Text41.Text") = " " Input.Find("whoisonair.gtzip").Text("Text51.Text") = " " Input.Find("whoisonair.gtzip").Text("Text61.Text") = " " Input.Find("whoisonair.gtzip").Text("Text71.Text") = " " Input.Find("whoisonair.gtzip").Text("Text71.Text") = " " API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg31.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg41.Text",Value:="transparent") End If If inputNumber = 3 Then Input.Find("whoisonair.gtzip").Text("Text21.Text") = "caller2 onair OUT1" API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="red") Input.Find("whoisonair.gtzip").Text("Text11.Text") = " " Input.Find("whoisonair.gtzip").Text("Text31.Text") = " " Input.Find("whoisonair.gtzip").Text("Text41.Text") = " " API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg11.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg31.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg41.Text",Value:="transparent") End If If inputNumber = 4 Then Input.Find("whoisonair.gtzip").Text("Text31.Text") = "caller3 onair OUT1" API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg31.Text",Value:="red") Input.Find("whoisonair.gtzip").Text("Text11.Text") = " " Input.Find("whoisonair.gtzip").Text("Text21.Text") = " " Input.Find("whoisonair.gtzip").Text("Text41.Text") = " " API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg11.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg41.Text",Value:="transparent") End If If inputNumber = 5 Then Input.Find("whoisonair.gtzip").Text("Text41.Text") = "caller4 onair OUT1" API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg41.Text",Value:="red") Input.Find("whoisonair.gtzip").Text("Text11.Text") = " " Input.Find("whoisonair.gtzip").Text("Text21.Text") = " " Input.Find("whoisonair.gtzip").Text("Text31.Text") = " " API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg11.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="transparent") API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg31.Text",Value:="transparent") End If sleep (200) loop
The number in the variable AddHours(3), determines the other time zone from that of the running computer on which the script is running. The title is called uhr.gtzip, it is written in the first field of the title (changeable with the index number)
do while true Dim d1 As DateTime = DateTime.Now.AddHours(3) API.Function("SetText",Input:="uhr",SelectedIndex:="0" ,Value:=d1.ToString("dd/MM/yy H:mm:ss")) sleep(200) loop
In diesem Beispiel hat es im Titel in dem Eingang 5, 2 Logos.
In this example, in the title of Input5 it has 2 logos.
The result is 2 strings as follows:
C:\vMix\4ball\Futsal/Logos\SUI.png
C:\VMIX\4ball\Futsal/Logos\SVN.png
dim logo1 as string = "" dim logo2 as string = "" dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) logo1 = (x.SelectSingleNode("//input[@number=5]/image[1]").InnerText) logo2 = (x.SelectSingleNode("//input[@number=5]/image[2]").InnerText) ' console.writeline section is only for test purpose console.writeline(logo1) console.writeline(logo2)
original string:
Currently in Lexington, VA: 25 °F and Mostly Cloudy
<img src=\“https://vortex.accuweather.com/phoenix2/images/common/icons/38_31x31.gif”>
Shows everything before the sign “<”
Dim leftPart As String = string1.Split("<")(0)
Currently in Lexington, VA: 25 °F and Mostly Cloudy
the string to be edited is in a text field(Headline.Text) of a title (Title.gtzip), always case sensitive. A quotation mark (“) is replaced by a single quotation mark (').
Dim string1 as String = (Input.Find("Title.gtzip").Text("Headline.Text")) Dim string2 As String = string1.Replace( """", "'")
sleep(1000)
do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) dim word as string = (x.SelectSingleNode("//input[@number=1]").InnerText) console.writeline(word) 'or API to send to title sleep(500) loop
'Fill in complete path to folder, end with \ dim FILEPATH as string = "C:\User\Example\Folder\" dim FILENAME as string = "Caller_Log.txt" ' Leave the rest untouched dim FILE as string = FILEPATH & FILENAME dim callers() as string = {"caller1","caller2","caller3","caller4"} dim nodes() as string = {"//input[@number=1]", "//input[@number=2]", "//input[@number=3]", "//input[@number=4]"} dim i as integer = 0 do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) do while i < 4 dim node as string = nodes(i) dim caller as string = callers(i) dim name as string = (x.SelectSingleNode(node)).InnerText If name <> caller: Dim callerid As string = (i+1).ToString() Dim timeStamp As DateTime = DateTime.Now Dim callertxt as string = "- New caller at ID" & " " & callerid & " - "& name Dim writenew as string = timestamp & " " & callertxt System.IO.File.AppendAllText(FILE, writenew + Environment.NewLine) Console.writeline(writenew) callers(i) = name End If i = i+1 loop i = 0 sleep(1000) loop
Query recording status via API and write the value in a Title Input as display. A sample title from the GT Library is selected as the title. Title 0- The Classic Blue.gtzip
dim isrecording as string = "" ' do while true/loop, checks continuously until the script is stopped do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) ' are we recording? isrecording = (x.SelectSingleNode("/vmix/recording").InnerText) ' write the result in a title and change the color accordingly if isrecording = true API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="AUFZEICHNUNG LÄUFT") API.Function("SetTextColour",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="red") else API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="AUFZEICHNUNG STOP") API.Function("SetTextColour",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="green") end if sleep(500) loop
Sample title: remainingtime.gtzip
' Check the remaining time of the active running video and display it in a title.. dim position as string = "" dim duration as string = "" dim activeinput as string = "" dim Timeleft as double = 0 dim triggertime as integer = 10 '10 Sekunden before end do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) activeinput = (x.SelectSingleNode("//active").InnerText) duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value) position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value) Timeleft= Double.Parse(duration)-Double.Parse(position) Timeleft = Timeleft / 100 dim Timingleft as integer = CInt(Timeleft) Timingleft = Timingleft / 10 dim Minutes as integer = Timingleft \ 60 dim Seconds as integer = Timingleft Mod 60 'bracket out for testing ' console.writeline(Timingleft) ' console.writeline(Seconds) 'edit the text "remaining time" as needed dim ThisTime as string ThisTime = "remaining time - " + Minutes.ToString("00") + ":" + Seconds.ToString("00") if Timingleft < 60 dim TimeRemaining as string TimeRemaining = "remaining time - 00:" + Seconds.ToString("00") API.Function("SetText", Input:="remainingtime.gtzip", SelectedIndex:="0", Value:=Timeremaining) if Timingleft < 30 API.Function("SetTextColour",Input:="remainingtime.gtzip",Value:="red") else API.Function("SetTextColour",Input:="remainingtime.gtzip",Value:="orange") end if else API.Function("SetText",Input:="remainingtime.gtzip",SelectedIndex:="0" ,Value:=ThisTime) API.Function("SetTextColour",Input:="remainingtime.gtzip",Value:="green") end if sleep(50) Loop
This example fades out the sound slowly of the video 2 seconds (triggertime) before the video is finished.(triggerduration).
dim position as string = "" dim duration as string = "" dim activeinput as string = "" dim Timeleft as double = 0 dim triggertime as integer = 2000 '2 seconfs before end dim triggerduration as integer = 500 'fade out time(fade) do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) activeinput = (x.SelectSingleNode("//active").InnerText) duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value) position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value) Timeleft= Double.Parse(duration)-Double.Parse(position) if Timeleft < triggertime API.Function("SetVolumeFade",Input:=activeinput.tostring(),Value:="0," & triggerduration.tostring()) ' do here what you want to do, the example slowly fades out the sound end if sleep(500) Loop
http://127.0.0.1:8088/api/?Function=SetPosition&Input=Video.mp4&Value=2000
Input 0 is OUTPUT (PGM)
"Function=Play&Input=1")
Dim one as integer = Convert.toInt32(Input.Find("Tally.gtzip").Text("One.Text")) Dim Two as integer = Convert.toInt32(Input.Find("Tally.gtzip").Text("Two.Text")) API.Function("SetText",Input:="Tally.gtzip",SelectedName:="Total.Text",Value:=(One + Two).tostring)
During a recording, the editor can press a key that triggers the script. A timestamp is written to a text file, which makes it easier to find desired points in the recording.
' Text file for the timestamp dim FILENAME = "D:\out.txt" ' Get recording duration dim xml = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) dim Duration = integer.parse((x.SelectSingleNode("//recording/@duration").Value)) dim Second = math.floor(Duration mod 60) dim Minute = math.floor((Duration / 60) mod 60) dim Hour = math.floor((Duration / (60 * 60)) mod 60) ' write tijmestamp to textfile System.IO.File.AppendAllText(filename, string.format("{0:00}:{1:00}:{2:00}"&Environment.NewLine, Hour, Minute, Second))
There must be a multiviewer Quadsplitt, with a title overlay(Quadsplitt_Rotlicht.gtzip).
download quadsplitt_rotlicht.gtzip GT Template
Since in vMix coloured rectangles of a title cannot be recoloured*, but text can, I use the ARIAL ASCII character U 2588, Full Block █. The colour of the text character can be easily adjusted
*this is changed in vMix Version 25. In this version you can also change colors from drawed rectangles, created in GT Title.
do while true Dim doc As New XmlDocument() doc.LoadXml(API.Xml) Dim root As XmlNode = doc.DocumentElement Dim node As XmlNode = root.SelectSingleNode("/vmix/active") Dim inputNumber as Integer = node.InnerXml If inputNumber = 1 Then Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOL.Text") = "Kamera 1 ONAIR" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOR.Text") = "Kamera 2" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUL.Text") = "Kamera 3" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUR.Text") = "PGM K1" API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG1.Text",Value:="red") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG2.Text",Value:="black") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG3.Text",Value:="black") 'API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG4.Text",Value:="black") end if If inputNumber = 2 Then Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOL.Text") = "Kamera 1" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOR.Text") = "Kamera 2 ONAIR" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUL.Text") = "Kamera 3" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUR.Text") = "PGM K2" API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG1.Text",Value:="black") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG2.Text",Value:="red") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG3.Text",Value:="black") 'API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG4.Text",Value:="black") end if If inputNumber = 3 Then Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOL.Text") = "Kamera 1" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextOR.Text") = "Kamera 2" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUL.Text") = "Kamera 3 ONAIR" Input.Find("Quadsplitt_Rotlicht.gtzip").Text("TextUR.Text") = "PGM K3" API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG1.Text",Value:="black") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG2.Text",Value:="black") API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG3.Text",Value:="red") 'API.Function("SetTextColour",Input:="Quadsplitt_Rotlicht.gtzip",SelectedName:="HG4.Text",Value:="black") end if sleep (200) loop
vMix sometimes makes something “different” out of a number that comes from a data source.
100.00 becomes 100
100.10 becomes 100.1
etc.
However, if the display 100.00 is always desired, this can be corrected via a looping script. In this example it is the title mytitle and the field Headline.Text.
do dim j as integer dim i As string = "" dim mystring as string = "" i = Input.Find("mytitle").Text("Headline.Text") j = CInt(i) myString = String.Format("{0:00}", j) API.Function("SetText",Input:="mytitle",SelectedName:="Description.Text",Value:=myString ) loop
Switches on the first multiviewer layer on the first 4 inputs and assigns inputs to them 11-14
Function=SetMultiViewOverlay&Input=1&Value=1,11 Function=MultiViewOverlayON&Input=1&Value=1 Function=SetMultiViewOverlay&Input=2&Value=1,12 Function=MultiViewOverlayON&Input=2&Value=1 Function=SetMultiViewOverlay&Input=3&Value=1,13 Function=MultiViewOverlayON&Input=3&Value=1 Function=SetMultiViewOverlay&Input=4&Value=1,14 Function=MultiViewOverlayON&Input=4&Value=1
or
API.Function("SetMultiViewOverlay",Input:="1",Value:="1,11") API.Function("MultiViewOverlayOFF",Input:="1",Value:="1")
ATTENTION: calling a script from a script takes time. So always set a sleep(200) after a more complex action.
API.Function("ScriptStart", , "MeinScript") sleep(200)
This example switches Input1 on/off to Overlay1 on the computer with the IP 192.168.10.10.
It is important to close the connection, as vMix does not do this itself.
Dim client = WebRequest.Create("http://192.168.10.10:8088/api/?Function=OverlayInput1&Input=1") Dim response = client.GetResponse() response.Close
' Copy all this into a new script, name the script and save it ' replace 13 with the input number of the photo list ' replace 14 with the input number you want to switch to ' use a trigger on your photo input to run the script (ontransitionin - scriptstart - name of the script) dim PhotoCompleted as string = "" ' a small delay, to ensure that the transition is completed, can also be set in the trigger. sleep(1000) do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) PhotoCompleted = (x.SelectSingleNode("//input[13]/@state").InnerText) if PhotoCompleted = "Completed" API.Function("Fade",Input:="14",Duration:="500") ' or any other function, you want to perform after all the photos have been displayed exit do end if sleep(100) loop
Starts an external programm from vMix and continues to execute the script when the external application is closed.
For example, a more complex external programme can be executed that would be difficult or impossible to solve with vMix Script.
Dim P As New Process P = Process.Start("notepad.exe") P.WaitForExit()
Starting an application (example: Notepad, with specified existing textfile)
Dim ExtApp As New ProcessStartInfo ExtApp.FileName = "notepad.exe" ExtApp.Arguments = "d:/demo.txt" ExtApp.UseShellExecute = True ExtApp.WindowStyle = ProcessWindowStyle.Normal Dim proc As Process = Process.Start(ExtApp)
This vMix script backs up all active scripts in vMix as individual text files to a predefined folder.
This can be used to make a backup of the scripts in use. This function is not provided in vMix. You can only export all scripts and shotcuts as a whole. When importing an existing export, any scripts added later will be deleted.
IMPORTANT, after an update the path must be adapted to the new version!
' Search for your User Config in the Appdata\local\studiocoast folder ' for me it looks like this: ' C:\Users\Peter_PC\AppData\Local\StudioCoast_Pty_Ltd\vMix64.exe_Url_pnmwemdfj\24.0.0.63\user.config ' IMPORTANT, after an update the path must be adapted to the new version! ' the script starts here Dim vMixConfig as string = "C:\Users\Peter_PC\AppData\Local\StudioCoast_Pty_Ltd\vMix64.exe_Url_pnmwemdfj\24.0.0.63\user.config" ' Determine where the individual scripts are to be stored Dim path as string = "D:\Myscripts\" ' if the path does not exist, it is created If(Not System.IO.Directory.Exists(path)) Then System.IO.Directory.CreateDirectory(path) End If ' initialize xml Dim document As XmlDocument = New XmlDocument() ' loads the config xml file document.Load(vMixconfig) ' gets the inner xml-string for the scripts dim innerxml as string = (document.SelectSingleNode("//setting[@name='Scripts']").InnerText) ' loads the existing scripts Dim doc As New XmLDocument() doc.LoadXML(innerxml) Dim nodeList As XmlNodeList = (doc.SelectNodes("//Script")) ' saves the scripts in the designated folder For Each node As XmlNode In nodeList Dim thefile As System.IO.Streamwriter 'Console.WriteLine(node("Name").InnerText ) thefile = My.Computer.FileSystem.OpenTextFileWriter(path + node("Name").InnerText + ".txt", False) thefile.WriteLine(node("Code").InnerText) thefile.Close() next
I have written a small application that does all this automatically.
Download exe download HERE as EXE
Download zip download HERE as ZIP
Since my small programmes are not digitally signed, this warning appears the first time I start them.
string1= string1.Replace(Environment.NewLine,String.Empty)
Fetches all text from a string up to the character <.
Dim leftPart As String = string1.Split("<")(0))
'Is a input Running or on Pause retrieved from the API xml
dim xml = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) dim StateOf = (x.SelectSingleNode("//input[@type='Replay']/@state").Value) 'oder 'dim StateOf = (x.SelectSingleNode("//input[@number='10']/@state").Value) if StateOf = true ' do something else ' do something else end if
Unfortunately, vMix does not allow simple public variables. A variable is only functional in the script and cannot be used by another script. Since writing to and reading from a title is quite fast, you can misuse it as a variable repository. The title is simply loaded at the end of the project and then forgotten. An example title here variablen.gtzip
Always write variables in the title, even integers, as strings in quotation marks! If an integer value has to be converted into a string, this is done with cstr()
Input.Find("variablen.gtzip").Text("i1.Text")="111" Input.Find("variablen.gtzip").Text("i2.Text")="222" Input.Find("variablen.gtzip").Text("s1.Text")="anything significant"
Reads variables from the title. When reading out, a string is always created; if this contains a numerical value, the string must then be converted into an integer value, cint().
dim var1 as string = Input.Find("variablen.gtzip").Text("i1.Text") dim var2 as string = Input.Find("variablen.gtzip").Text("i2.Text") dim i1 as integer = cint(var1) dim i2 as integer = cint(var2) ' console.writeline is for test purpose only console.writeline(i1) console.writeline(i2) console.writeline(i1+i2)
dim Directory as string ="C:\Testdir" If (Not System.IO.Directory.Exists(Directory)) Then System.IO.Directory.CreateDirectory(Directory) End If
dim Filenameas string ="C:\Testdir\Datenbank.xml" If (Not System.IO.File.Exists(Filename)) Then My.Computer.FileSystem.WriteAllText(Filename, " ", True) End If
delete files in folder Dim path As String = "C:\Testdir" ' deletes all files in the directory path If Directory.Exists(path) Then For Each filepath As String In Directory.GetFiles(path) File.Delete(filepath) Next ' deletes all subfolders in the directory path For Each d as string in Directory.GetDirectories(path) Directory.Delete(d, true) Next End If sleep(1000)
dim FILELOCATION As string = "D:/" dim IMAGENAME As string = "" dim FILENAME As string = "" IMAGENAME = "flagge.png" FILENAME = FILELOCATION & IMAGENAME If System.IO.File.Exists(FILENAME) Then ' if the file exists, do something else ' if the file does not exist, do something else end if
In this example, the files are copied from the folder E:\Somewhere to a folder RECORD on the desktop.
Dim path As String = My.Computer.FileSystem.SpecialDirectories.Desktop + "\RECORD" If Directory.Exists(path) = False Then Try Directory.CreateDirectory(path) Catch ex As Exception 'errorhandling End Try End If My.Computer.FileSystem.CopyDirectory("E:\Somewhere ", path, True) sleep(1000)
For a different time, adjust the value 9999.
dim duration as string = "" dim activeinput as string = "" dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) activeinput = (x.SelectSingleNode("//active").InnerText) duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value) API.Function("SetPosition",Input:=activeinput ,Value:=(duration-9999) ) sleep(500)
The code is for a title that has 6 pages, which are automatically changed after 5 seconds
dim x as integer Dim Index as integer =0 Do while Index <=100 for x = 1 to 6 sleep(5000) api.Function("SelectIndex",Input:="Test.gtxml",Value:=x) next x index +=1 loop
' triggers a function at a specific time of day (16:00) ' in this example, INPUT1 ("1") is placed on overlay1 ' set the time here dim triggertime as string = "16:00" Do While True If triggertime = DateTime.Now.ToString("HH:mm") Then 'use hh:mm for 12H display (AM/PM) ' here comes the function that is to be triggered at a certain time API.Function("OverlayInput1In",Input:="1") ' replace "1" with the input number you want Exit do End If sleep(1000) Loop
' triggers a function at a specific time of day (16:00) ' in this example streaming 1 is started ' Stream1: Value:="0" ' Stream2: Value:="1" ' Stream3: Value:="2" ' set the time here dim triggertime as string = "16:00" Do While True If triggertime = DateTime.Now.ToString("HH:mm") Then ' Here comes the function that is to be triggered at a certain time, Start Streaming 1 API.Function("StartStreaming",Value:="0") Exit do End If sleep(1000) Loop
The gtzip template has ONE bar, consisting of 579 individual text fields (hard work , each 3 pixels wide, each with the Arial “full block” characterl █
Load the GT-Title growingbars1.gtzip into vMix.download growingbar1.gtzip
Adjust the size and position of the first bar with the position sliders of this input.
Create 3 virtual copies of this bar.
Move these additional bars to the correct position in each INPUT, using the position sliders.
(IMPORTANT) Rename the 3 copies to
growingbars2.gtzip
growingbars3.gtzip
growingbars4.gtzip
Lade einen transparenten Color-Input.
Füge die 4 growingbar-Titel in den Multiviewer ein.
Dieser Eingang ist dann dein fertiges Overlay-Signal.
Damit sich die Balken bewegen, werden 2 Skripte benötigt.
eines, um die Balken zu löschen
eines, um die Balken wachsen zu lassen
Load a transparent colour input.
select the 4 growingbar titles into the multiviewer.
This input is then your finished overlay signal.
For the bars to move, 2 scripts are needed.
one to erase the bars
one to make the bars grow
The scripts are loaded with the preset.
For testing please put the files on the desktop.
-Projekt growingbars.vmix
-GT Titel growingbar1.gtzip
In the script growingbars all necessary variables can be changed.
(colour, transparency of the bar, speed, percentages)
The script is designed for a sum of 100%.
The bar width is automatically adjusted, i.e. the participant with the highest percentage receives the full bar width.\
Shortcut keys in the project:
C deletes the bar
G starts the bar
all needed files (Projekt, Titel) are here
' this script is made for 4 bars, please extend it for more bars dim i as integer 'variable for the loop dim barcolor as string 'variable for the color of the bar dim fieldname as string 'variable for the Fieldname of the Textfield in the gtzip template dim barwidth as integer = 579 '579 textfields, each 3 pixels wide dim barspeed as integer = 0 'higher values = slower bar grow, 0 = fastest possible dim barpause as integer = 450 'waits xx miliseconfs, before painting the next bar 'change here the values from your competition (sum of the 4 maximal 100%) 'dont change the part "dim Percentage_Candidate1 as integer =", only the digits at the end of the line! dim Percentage_Candidate1 as integer = 31 dim Percentage_Candidate2 as integer = 25 dim Percentage_Candidate3 as integer = 19 dim Percentage_Candidate4 as integer = 25 'this sets the color of the bars 'you can use all colors from here: https://www.w3schools.com/colors/colors_names.asp 'color example "#FFD700" is GOLD 'normal color = # + 6 HEX codes "#FFD700" 'transparent color = # + 8 HEX codes, the first two characters are for tranparence, "#CCFFD700" CC = 70% transparent barcolor = "#CCFFD700" '______________________nothing to change from here ____________________________ 'this section calculates the maximal barwidth (500) to the winner percentage dim Bar_width_1 as integer dim Bar_width_2 as integer dim Bar_width_3 as integer dim Bar_width_4 as integer dim maximalvalue as integer = Percentage_Candidate4 if Percentage_Candidate3 > Percentage_Candidate4 then maximalvalue = Percentage_Candidate3 if Percentage_Candidate2 > Percentage_Candidate3 then maximalvalue = Percentage_Candidate2 if Percentage_Candidate1 > Percentage_Candidate2 then maximalvalue = Percentage_Candidate1 Bar_width_1 = barwidth /maximalvalue*Percentage_Candidate1 Bar_width_2 = barwidth /maximalvalue*Percentage_Candidate2 Bar_width_3 = barwidth /maximalvalue*Percentage_Candidate3 Bar_width_4 = barwidth /maximalvalue*Percentage_Candidate4 'this paints the bars, one after the other for i = 1 to Bar_width_1 fieldname = "T"+cstr(i) + ".Text" API.Function("SetTextColour",Input:="growingbar1.gtzip",SelectedName:= fieldname ,Value:=barcolor) SLEEP (barspeed) next SLEEP (barpause) for i = 1 to Bar_width_2 fieldname = "T"+cstr(i) + ".Text" API.Function("SetTextColour",Input:="growingbar2.gtzip",SelectedName:= fieldname ,Value:=barcolor) SLEEP (barspeed) next SLEEP (barpause) for i = 1 to Bar_width_3 fieldname = "T"+cstr(i) + ".Text" API.Function("SetTextColour",Input:="growingbar3.gtzip",SelectedName:= fieldname ,Value:=barcolor) SLEEP (barspeed) next SLEEP (barpause) for i = 1 to Bar_width_4 fieldname = "T"+cstr(i) + ".Text" API.Function("SetTextColour",Input:="growingbar4.gtzip",SelectedName:= fieldname ,Value:=barcolor) SLEEP (barspeed) next SLEEP (barpause)
generate random number per script. title example: wuerfel.gtzip
Static Generator As System.Random = New System.Random() dim i as integer dim fieldname as string = "Zahl.Text" dim zahlrnd as integer for i = 1 to 20 zahlrnd = Generator.Next(1, 6) API.Function("SetText",Input:="wuerfel.gtzip",SelectedName:= "Zahl.Text",Value:=zahlrnd ) sleep(100) next
generate random color in a Title textfield per script. title example: textfarbe.gtzip
Static Generator As System.Random = New System.Random() dim i as integer dim fieldname as string ="Text.Text" dim color as string dim colorrnd as integer for i = 1 to 20 colorrnd = Generator.Next(1, 11) 'you can use colornames from https://www.w3schools.com/colors/colors_names.asp if colorrnd = 1 then color = "aqua" if colorrnd = 2 then color = "blue" if colorrnd = 3 then color = "Chartreuse" if colorrnd = 4 then color = "Crimson" if colorrnd = 5 then color = "GreenYellow" if colorrnd = 6 then color = "orange" if colorrnd = 7 then color = "LawnGreen" if colorrnd = 8 then color = "red" if colorrnd = 9 then color = "yellow" if colorrnd = 10 then color = "white" API.Function("SetTextColour",Input:="textfarbe.gtzip",SelectedName:= fieldname ,Value:=color) sleep(100) 'damit man es sieht next
SetTextVisible can switch a text field on or off (toggle)
SetTextVisibleON can switch a text field on
SetTextVisibleOFF can switch a text field off
the same can be done with an image:
API.Function(“SetImageVisible”,Input:=“visibledemo.gtzip”,SelectedName:=“Image1.Source”)
Unfortunately, the rectangles or other shapes created in the GT Titler, until version 24, can neither be recoloured nor made visible/invisible.
Example title here: visibledemo.gtzip
do while true API.Function("SetTextVisible",Input:="visibledemo.gtzip",SelectedName:="TextBlock1.Text") API.Function("SetImageVisible",Input:="visibledemo.gtzip",SelectedName:="Image1.Source") sleep(500) loop
vMix has 3 additional small mixer inputs, which can also be used well for various script-controlled functions. The advantage of the 3 additional mixers is that each input can also be blended. (The mixers are only available from the 4K version)
A mixer input is generated with the small up arrow next to the Add Input button.
set Input 1 in Mix2 Preview
API.Function("PreviewInput",Input:=1,Mix:=1)
set Input 1 in Mix2 Output
API.Function("ActiveInput",Input:=1,Mix:=1)
fade Mix2
API.Function("Fade",Input:=0,Mix:=1) ' INPUT 0 is always PGM (OUTPUT)
It is sometimes a bit confusing/tricky to find the right xpath to retrieve certain data from an XML file, be it within a script or in the XML data source manager. A few helpful links that can generate an xpath for you. However, you may need to adjust the results a bit depending on whether you use it in a script or in a data source manager.
http://xmltoolbox.appspot.com/xpath_generator.html (returns a result based on a selection)
https://www.easycodeforall.com/XPathUtility.jsp (outputs a whole list of possible xpaths, also has a few other goodies)
With Datasource, text fields of a title can be coupled with external data. The following function as data:
-Excel
-Google Sheet
-JSON
-RSS
-Text
-XML
Since vMix makes its API data available as XML, the Datasource Manager of vMix can of course also read and evaluate its own data. To do this, open a title input and right-click in the small title field. Demo title here: datasource_demo.gtzip
1. Right mouse button in the title window, Title Editor
2. Data Source
3. Manage
4. Data Source, +, XML
5. Name,
e.g. vmix API, http://127.0.0.1:8088/api/?, and a valid XML node such as //inputs//input[@audiobusses]
then, press OK.
6. This should then look like this:
7. After that, the individual data can be assigned to any text fields in the title.
Note: data only comes if something is written to the XML. If none of the inputs has audio, the node in the example will simply get NOTHING.
In the example, the Google Sheet is called “Women's Football Google Sheet” and the table “Servette.\\” If you now link title data with selected row, a row of the table can be selected via API. A table can be scrolled through like this.
API.Function("DataSourceSelectRow",Value:="Frauenfussball Google Sheet,Servette,2")
shows, until the script is stopped by hand, every 5 seconds one of 10 rows from a table Google Sheet “Women's Football Google Sheet” and the table “Results”.
while (true) For i As Integer = 1 to 10 API.Function("DataSourceSelectRow",Value:="Frauenfussball Google Sheet,Resultate," &i) Sleep(5000) Next end while
RTMP Stream URL for stream1
(Stream2 “Input:=2”, Stream 3 “Input:=3”)
API.Function("StreamingSetURL","Input=1", "rtmp://x.xx123456.i.akamaientrypoint.net/EntryPoint")
Streamkey
API.Function("StreamingSetKey","Input:=1", "2222oioioi23456")
OPTIONAL
User
API.Function("StreamingSetUsername","Input:=1", "USER99")
Password
API.Function("StreamingSetPassword","Input:=1", "123456")
Request streaming status via API and write the value in a title input as a display. An example title from the GT Library is selected as the title. Title 0- The Classic Blue.gtzip
dim isstreaming as string = "" ' do while true/loop,checks continuously until the script is stopped do while true dim xml as string = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml) ' are we streaming? isstreaming = (x.SelectSingleNode("/vmix/streaming[1]").InnerText) ' write an answer in a title and change the colour accordingly if isstreaming = true API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="Streaming is running") API.Function("SetTextColour",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="red") else API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="Streaming is stopped") API.Function("SetTextColour",Input:="Title 0- The Classic Blue.gtzip",SelectedName:="Headline.Text",Value:="green") end if sleep(500) loop
zoom
API.Function("SetZoom",Input:="1",Value:="0.5")
tilt
API.Function("SetPanX",Input:="1",Value:="0.5")
API.Function("SetPanY",Input:="1",Value:="0.5")
This requires a script and a web browser input in EVERY project. When the project is started, the website is called once. Since a vMix API command can also be sent via the web browser, this command triggers the script.
The web browser INPUT has the following URL:
http://127.0.0.1:8088/api/?Function=ScriptStart&Value=startexternal
The following script with the name “startexternal” must be present on the computer:
API.Function("StartExternal") sleep (1000) API.Function("StopExternal") sleep (1000) API.Function("StartExternal")
With this trick, almost any function can be executed as an Autostart command.