Benutzer-Werkzeuge

Webseiten-Werkzeuge


scripting

Dies ist eine alte Version des Dokuments!


Scripting

ein paar Beispiele sind aus „doggy's“ SCRIPTING FOR DUMMIES aus den vMix Forum.

Scripting ist innerhalb von vMix mit dem eingebauten Editor möglich oder als externer Befehl via Browser. Die Zusammenstellung der Beispiele ist unvollständig. Im Anhang hat es eine Auflistung der zurzeit bekannten API-Befehle. vMix Scripting unterstützt VB.NET beim Schreiben deines Skripts. Alle Variablen sind Lokal, es gibt leider keine Public Variablen. Man kann irgendwelche nicht sichtbaren Textfelder als Pubic Variablen zweckentfremden.
Bei Input kann entweder der Filename des Titels(Gross-Kleinschreibung beachten) oder die InputNummer verwendet werden.

Die Beschreibung auf der vMix Seite ist etwas dürftig, trotzdem lohnt sich immer ein Blick dorthin.
vMix API Website
Hier die aktuell gültige Liste der Befehle in der Übersicht.
Shortcut Übersicht


4 verschiedene Arten, ein script zu schreiben

es gibt 4 verscheidene Arten ein script zu schreiben. Schlussendlich machen die Varianten alle das selbe. Im normalfall reicht in vMix Editor die einfachste Variante. (WEB)

–VB.net     kann aber mit variablen umgehen, WEB kann das nicht.
API     enspricht VB net
–WEB     ohne variablen, kurz und einfach, reicht für die meisten internen scripte.
–HTTP     sendet den API Befehl via Browser oder

VB.net

Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "Some Text"


API

API.Function("SetText",Input:="1",SelectedName:="Headline.Text",Value:="Same Text")


WEB

Function=SetText&Input=1&SelectedIndex=0&Value=Some Other Text


HTTP

http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Some Text




Hello World Beispiel

Dieses Beispiel verwendet den mitgelieferten Titel NewsHD und schreibt Hello World in das Feld Headline

Input.Find("NewsHD.xaml").Text("Headline") = "Hello World!"


oder anders ausgedrückt:

dim i = Input.Find("NewsHD.xaml")\\
i.Text("Headline") = "Hello World!"


Audio

Audio Bus der Quelle 1 Einschalten (grüner Lausprecher)

Function=AudioON&Input=1


Audio Bus der Quelle 1 auf Audio Ausgang D routen

Function=AudioBusON&Input=1&Value=D


Audio Bus der Quelle 2 auf Audio Ausgang Master routen

Function=AudioBusON&Input=2&Value=M


Audio Bus der Quelle 1 vom Master wegrouten

Function=AudioBusOFF&Input=1&Value=Master


Audio Bus der Quelle 3 vom D wegrouten

Function=AudioBusOFF&Input=1&Value=D


Audio follow Video vom Eingang 1 abschalten

Function=AudioAutoOff&Input=1


Video

Eingang 4 Video auf OUTPUT routen

Function=Activeinput&Input=4


oder

Function=Cutdirect&Input=2&Value=2


Eingang 3 Video auf Preview routen

Function=Previewinput&Input=4


Eingang 1 Video auf OUTPUT2 routen

Function=SetOutput2&Input=1&Value=1


Eingang mit einem bestimmten Namen auf die Linie routen

Input.Find("YourInput").Function("Cut")


Titel / Text

Ändert Text in einem bestimmten Feld

Input.Find("Title 0- The Classic Blue.gtzip").Text("Headline.Text")= "Text geändert"


oder

API.Function("SetText",Input:="Title 0- The Classic Blue.gtzip",SelectedName:=" Headline.Text ",Value:="Text geändert ")


Ändert Schrift Farbe eines bestimmten Textfeldes, es gehen argb Werte oder sonst als Farbe (red, blue, black, transparent etc.)

API.Function("SetTextColour",Input:="whoisonair.gtzip",SelectedName:="hg21.Text",Value:="transparent")


Titel / Text via browser

Als IP Adresse benutzt man folgendes:
-127.0.0.1 wenn der Browser auf demselben Computer läuft, wie vMix.
-vMixIP wenn der Browser auf einem anderen Computer im selben Netzwerk läuft.

Aendert ein (Logo, Foto etc.)

http://127.0.0.1:8088/API/?Function=SetImage&Input=Titel.gtzip"&SelectedName=LOGO.Source&Value=C:\VMIX\ch.png


Setzt ein Bild (Logo, Foto etc.) auf unsichtbar (sichtbar SetImageVisibleOn)

http://127.0.0.1:8088/API/?Function=SetImage&Input=Titel.gtzip&Image=LOGO.Source&Value=C:\VMIX\ch.png


Inputs

Alle diese Funktionen erzeugen einen neuen Eingang

Lädt ein Titel aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=Xaml|C:\VMIX\Name.gtzip


Lädt ein Video aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=Video|c:\path\to\video.avi


Lädt ein Bild aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=Image|c:\path\to\image.jpg


Lädt einen Bilder Ordner aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=Photos|c:\path\to\folder


Lädt eine Video Playlist aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=VideoList|c:\path\to\playlist.m3u


Lädt ein Audiofile aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix

http://127.0.0.1:8088/API/?Function=AddInput&Value=AudioFile|c:\path\to\audio.wav


Lädt eine Powerpoint Präsentation aus einem bestimmten Verzeichnis in einen neuen Eingang in vMix
(ich glaube es funktionieren nur Folien ohne Videos oder Audios)

http://127.0.0.1:8088/API/?Function=AddInput&Value=PowerPoint|c:\path\to\powerpoint.pptx


Diverses

Wartet 1 Sekunde

sleep(1000)


ein script aus einem anderen script aufrufen, in diesem Fall das vMix Script allaudiobusDoff
Diese Funktion nutzt VB.NET als Programmiersprache, VB Net ist ein Teil der Scripting Funktionen.

Function=ScriptStart&Value=allaudiobusDoff


Schaltet bei allen Eingängen den AudioBus D aus

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

‘wieviele Eingänge sind aktiv
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


Scripting via Browser

Ändert Text in einem bestimmten Feld 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


Ändert Textfarbe in einem bestimmten Feld via Browser

http://127.0.0.1:8088/api/?Function=SetTextColour&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=red


komplexeres Beispiel

in welchem zuerst die aktive Input Nummer festgestellt wird, dann aufgrund der Inputnummer eine Aktion erfolgt. Es läuft als Loop, also solange jemand das Script startet und nicht wieder anhält.

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


Gibt den Names eines vMix Callers vom Input 1

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

Holt Audio Titelname aus einem Input

This script reads the current title of a playlist and writes it formatted into a field of a title input

In diesem Beispiel verwende ich den in vMix enthaltenen Titel „ Title 33- On the shelf- Peach.gtzip “ und schreibe den Text in das Feld „Headline.Text“. Mein List-Input ist Input2. Bitte passe diese (Titel, Feld und List-Input-Nummer) für Ihr Projekt an.

I use a list of MP3 audiofiles. 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

String formatieren

vMix macht manchmal aus einer Zahl, welche von einer Datenquelle stammt, etwas „anderes“.
aus 100.00 wird 100
aus 100.10 wird 100.1
etc.
Falls aber immer die Anzeige 100.00 gewünscht ist, kann das via ein loopendes Script korrigiert werden. In diesem Beispiel ist es der Titel mytitle und das Feld 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

Multiviewer einschalten und belegen

Schaltet auf den ersten 4 Inputs den ersten Multiviewer Layer ein und belegt diese mit Inputs 10-14

Function=SetMultiViewOverlay&Input=1&Value=1,11
Function=MultiViewOverlayON&Input=1&Value=1&Index=11

Function=SetMultiViewOverlay&Input=2&Value=1,12
Function=MultiViewOverlayON&Input=2&Value=1&Index=12

Function=SetMultiViewOverlay&Input=3&Value=1,13
Function=MultiViewOverlayON&Input=3&Value=1&Index=13

Function=SetMultiViewOverlay&Input=4&Value=1,14
Function=MultiViewOverlayON&Input=4&Value=1&Index=14

Funktion zu einem bestimmten Tageszeitpunkt auslösen

Einen Titel zu einer bestimmten Zeit zusetzen

'löst eine Funktion zu einem bestimmten Tageszeitpunkt aus (16:00)
'in diesem Beistpiel wird der Eingang 1 ("1") auf den Overlay1 gelegt

'hier die Zeit vorgeben
dim triggertime as string = "16:00"

Do While True
     If triggertime = DateTime.Now.ToString("HH:mm") Then      'bei 12H Anzeige (AP/PM) hh:mm verwenden
          ' Hier kommt die Funktion, welch zu einem bestimmten Zeitpunkt ausgelöst werden soll
           API.Function("OverlayInput1In",Input:="1")  '"ersetze "1" mit der von dir gewünschten Input Nummer
           Exit do
     End If
     sleep(1000)
Loop

Streaming zu einem bestimmten Zeitpunkt starten

'löst eine Funktion zu einem bestimmten Tageszeitpunkt aus (16:00)
'in diesem Beistpiel wird Streaming 1 gestartet
'Stream1:    Value:="0"
'Stream2:    Value:="1"
'Stream3:    Value:="2"

'hier die Zeit vorgeben
dim triggertime as string = "16:00"

Do While True
     If triggertime = DateTime.Now.ToString("HH:mm") Then
          ' Hier kommt die Funktion, welch zu einem bestimmten Zeitpunkt ausgelöst werden soll, Start Streaming 1
           API.Function("StartStreaming",Value:="0") 
           Exit do
     End If
     sleep(1000)
Loop

Wechsle Page in Titel alle 5 Sekunden

Der Code ist für einen Titel, welcher 6 pages hat, welche nach 5 Sekunden automatisch gewechselt werden.

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
scripting.1605544702.txt.gz · Zuletzt geändert: 2023/10/20 20:26 (Externe Bearbeitung)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki