logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

26 Pages123>»
Options
Go to last post Go to first unread
doggy  
#1 Posted : Sunday, January 5, 2020 6:49:58 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
For creating a script go to Settings->Scripting
All further Logics are in vb.net

Any reference to API.XML() is what one can find/see at http://127.0.0.1:8088/api (or local IP)


Further details are in the Help Files which can be accessed by clicking the question mark (?) in the top right corner of your vMix window

One can call a script using a shortcut or a Trigger with the function "ScriptStart"

Code:
'doing some input controls
Input.Find("YourInput").Function("Cut")
API.Function("Pause",Input:=10)


Code:
'See Shortcuts to get idea of elements used in a function 
'SelectedName (or SelectedIndex) instead of Title seen in Shortcut creation options

'Change an image in a title 
API.Function("SetImage",Input:="SomeTitle.gtzip",SelectedName:="Image1.Source",Value:="c:/fotoname.png")

'Change/Add the input of a multilayer Input
API.Function("SetMultiViewOverlay",Input:="InputWithMultiview",Value:="3,inputnameToAddToLayer3")



Code:
'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)
'or
dim StateOf = (x.SelectSingleNode("//input[@number='10']/@state").Value)
Console.WriteLine(StateOf)


Code:
'wait for a second in a script :-)
Sleep(1000)


Code:
'çhecking if a file exists based on the name in the TextBlock Headline.Text of a title
dim FILELOCATION As string = "D:/"
dim IMAGENAME As string = ""
dim FILENAME As string = ""

IMAGENAME  = Input.Find("TitleName").Text("Headline.Text")

FILENAME = FILELOCATION & IMAGENAME & ".png"

If System.IO.File.Exists(FILENAME) Then
   'write to the console of the scripteditor
   Console.WriteLine("The file allready exists")
else
   Console.WriteLine("Nope")
end if
thanks 15 users thanked doggy for this useful post.
tomaszek117 on 1/6/2020(UTC), stevespaw on 1/6/2020(UTC), stigaard on 1/8/2020(UTC), cho123 on 4/10/2020(UTC), avsoundguy on 5/8/2020(UTC), DWAM on 5/23/2020(UTC), studiodelta on 9/6/2020(UTC), CamStol on 11/13/2020(UTC), worldeye on 11/25/2020(UTC), stergi on 4/8/2021(UTC), hardayildiz on 8/20/2021(UTC), filipe.shakeit on 10/8/2021(UTC), jpetrie on 12/30/2021(UTC), nikosman88 on 1/11/2022(UTC), Ario on 1/6/2023(UTC)
doggy  
#2 Posted : Sunday, January 5, 2020 7:13:14 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
thanks 8 users thanked doggy for this useful post.
rudyengels on 4/6/2020(UTC), stigaard on 5/14/2020(UTC), studiodelta on 7/31/2020(UTC), worldeye on 11/25/2020(UTC), David_in_Philly on 12/10/2020(UTC), tatamata on 12/26/2020(UTC), jpetrie on 12/30/2021(UTC), monamiga on 12/20/2022(UTC)
elvis55  
#3 Posted : Sunday, January 5, 2020 8:22:20 AM(UTC)
elvis55

Rank: Advanced Member

Groups: Registered
Joined: 3/17/2017(UTC)
Posts: 415
Switzerland
Location: Luzern - Schweiz

Thanks: 61 times
Was thanked: 55 time(s) in 49 post(s)

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
doggy  
#4 Posted : Sunday, January 5, 2020 12:14:53 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Originally Posted by: elvis55 Go to Quoted Post

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.



Should be fixed
doggy  
#5 Posted : Thursday, January 9, 2020 12:27:21 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
They all do the same thing ;-)

Shortcut, Http Web API , Scripting To change a text in a title
as example


Shortcut

Shortcut.JPG (106kb) downloaded 27 time(s).


NOTE: 'Title' becomes 'SelectedName' or 'SelectedIndex' depending if you use the reference name or it position(index)

HTTP Web API in Browser

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

<! or >

http://127.0.0.1:8088/api/?Function=SetText&Input=1&SelectedIndex=0&Value=Some Text



Scripting

Code:

'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
Dim client = WebRequest.Create("http://127.0.0.1:8088/api/?Function=SetText&Input=Title 0- The Classic Blue.gtzip&SelectedName=Headline.Text&Value=Some Text")
Dim response = client.GetResponse()
response.Close


thanks 2 users thanked doggy for this useful post.
stigaard on 4/16/2020(UTC), jpetrie on 12/30/2021(UTC)
g-mo  
#6 Posted : Wednesday, January 15, 2020 10:04:49 AM(UTC)
g-mo

Rank: Advanced Member

Groups: Registered
Joined: 12/3/2013(UTC)
Posts: 117
Location: Arizona

Thanks: 8 times
Was thanked: 6 time(s) in 6 post(s)
Thanks for posting this it has helped me immensely! I'm pretty versed on scripting native vmix commands now.

How would one script for watching a data source change?
doggy  
#7 Posted : Wednesday, January 15, 2020 3:13:23 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Quote:
How would one script for watching a data source change?


Would need to be more specific !
g-mo  
#8 Posted : Wednesday, January 15, 2020 11:54:18 PM(UTC)
g-mo

Rank: Advanced Member

Groups: Registered
Joined: 12/3/2013(UTC)
Posts: 117
Location: Arizona

Thanks: 8 times
Was thanked: 6 time(s) in 6 post(s)
Here's what I'm working with....

Ideally, I would like the white bar to fade in when the results change. Currently the data resides in a google sheet, but will more than likely go back to an xml. I would like it to auto next through the sheet and fade out once the ticker scrolls the last line of data. I have used a script to fade out after a certain number of data rows have shown but the number of rows changes often and we are having to calculate them manually and input the delay manually.

I was having to fade in and out manually and its just too time-consuming to use in production. If anyone wants to take a look at the actual project everything can be downloaded at https://usabmx.sharefile.com/d-s8d939c5f4284067a

UserPostedImage
doggy  
#9 Posted : Thursday, January 16, 2020 12:19:17 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Quote:
Ideally, I would like the white bar to fade in when the results change.


Wrong place to ask , this is title related. Advice is to check out the GT title tutorial videos etc (workign with data sources, data change ... all have videos about it

When number of rows changes you need to make a test in a script. Advice is look up some vb.net tutorials on how to loop through something until a criteria is met , That's the whole point of scripting , taking manual decision making away from you

Be aware of using the right terms in a post : titles, textblocks, tickers to not create confusions


WHy use green background ?
Where is your ticker ? ( a textbox with a scroll animation is NOT a ticker be it simulates one )
g-mo  
#10 Posted : Thursday, January 16, 2020 1:59:06 AM(UTC)
g-mo

Rank: Advanced Member

Groups: Registered
Joined: 12/3/2013(UTC)
Posts: 117
Location: Arizona

Thanks: 8 times
Was thanked: 6 time(s) in 6 post(s)
I'm only looking for scripting help that will trigger the fade actions.

There are two inputs in vmix at play here.
basic_transfers.xaml
Ticker 3-Clear.gtzip
Ticker 3-Clear.gtzip sits on top of basic_transfers.xaml. Originally I had these two combined in a single GT title but was having issues with the datachange ticker animation. In a bind, I separated them.
Both read from the same data source. Column 1 feeds basic, column 2 feeds the ticker.
Ideally, I would like to have both fade in when new data is added to the google sheet and fade out when the final line of data is displayed. Hope that makes sense.

The green background was added to feed this out of vmix into an older switcher that was in the venue.
doggy  
#11 Posted : Tuesday, January 21, 2020 4:35:54 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Not limited for checking recording status ;-)

Code:
' Checking recording status from the API xml (127.0.0.1:8088/API)
' and display in a Title Input 

dim isrecording as string = ""

'lets keep checking
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("//recording").InnerText)

'used at debugging stage
   console.writeline(isrecording)

'put a response in a title and change color accordingly
  if isrecording  = true
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="RECORDING in PROGRESS")
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
  else
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="ALL CLEAR")
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
 end if

sleep(500)
loop




am sure it can be improved
thanks 2 users thanked doggy for this useful post.
dmwkr on 2/23/2020(UTC), nikosman88 on 2/4/2023(UTC)
g-mo  
#12 Posted : Tuesday, January 21, 2020 9:48:34 AM(UTC)
g-mo

Rank: Advanced Member

Groups: Registered
Joined: 12/3/2013(UTC)
Posts: 117
Location: Arizona

Thanks: 8 times
Was thanked: 6 time(s) in 6 post(s)
Originally Posted by: doggy Go to Quoted Post
Not limited for checking recording status ;-)

Code:
' Checking recording status from the API xml (127.0.0.1:8088/API)
' and display in a Title Input 

dim isrecording as string = ""

'lets keep checking
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("//external").InnerText)

'used at debugging stage
   console.writeline(isrecording)

'put a response in a title and change color accordingly
  if isrecording  = true
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="RECORDING in PROGRESS")
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
  else
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:="ALL CLEAR")
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
 end if

sleep(500)
loop




am sure it can be improved



Was this for me?
doggy  
#13 Posted : Tuesday, January 21, 2020 7:38:54 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Originally Posted by: g-mo Go to Quoted Post



Was this for me?



If you feel you can use it yes, but not specifically ?

Point of this thread it to give some leads and as extension to the help files .

I am far from an expert but to me the small examples helped me figure out more complete solutions just as fellow forum members have and still give me leads to achieve a solution so i hope they help you all.

Even if a specific function does not exist the fun is to figure out a way to achieve the same result it by looking outside the box sometimes.

I don't feel the need to post/give away complete scripts to specific wishes posted here or elsewhere in this forum even if i managed to make them as even then i had to search and try to complete them even when i might never use them myself but they do prove its possible and that's the "fun" part ;-).

And there is no harm in posting your own little tidbits you discovered ;-)



doggy  
#14 Posted : Thursday, January 23, 2020 1:53:10 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
From a recent request/discussion:

Goal: to switch 2 ACTIVE PIP overlays on screen with one shortcut
Individual overlay replacing or activating/deactivating as usual





Code:
' OVERLAYS SET TYPE = PIP  AND EFFECT = CUT. 
' Nothing holding you back to choose another effect

'lets have basket to hold some info
dim xml as string = API.XML()
dim ovl1input as string = ""
dim ovl2input as string = ""

'lets get all API xml data (http://127.0.0.1:8088/api)
dim x as new system.xml.xmldocument
x.loadxml(xml)

' let's see which of you inputs is currently on PIP overlays
ovl1input = (x.SelectSingleNode("//overlays//overlay[1]").InnerText)
ovl2input = (x.SelectSingleNode("//overlays//overlay[2]").InnerText)


if (ovl1input = nothing) or (ovl2input = nothing)
'we don't have 2 PIP overlays, no point in continuing then
return
end if

' lets switch you both
API.Function("OverlayInput1In",Input:=ovl2input)
sleep(50)
API.Function("OverlayInput2In",Input:=ovl1input)

'we are all good now ?
doggy  
#15 Posted : Sunday, February 23, 2020 12:18:58 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
From a recent request/discussion to trigger something BEFORE a video finishes


Code:
' Checking time left of active input
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 2000       '2 seconds before end
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

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 whatever one wants to do 

end if

sleep(500)
Loop
thanks 5 users thanked doggy for this useful post.
dmwkr on 2/23/2020(UTC), clafarge on 3/25/2020(UTC), Xtreemtec Media on 4/10/2020(UTC), studiodelta on 6/8/2020(UTC), nikosman88 on 2/4/2023(UTC)
doggy  
#16 Posted : Monday, April 6, 2020 6:27:27 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Retrieve the name of a vMix Video Caller


Most Basic Form
Code:

'get name of caller @ 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


Other option to retrieve them all through a xml datasource with xpath: //input[@type="VideoCall"]
thanks 2 users thanked doggy for this useful post.
stigaard on 4/16/2020(UTC), filipe.shakeit on 11/2/2021(UTC)
Xtreemtec Media  
#17 Posted : Friday, April 10, 2020 7:00:46 AM(UTC)
Xtreemtec Media

Rank: Member

Groups: Registered
Joined: 4/9/2020(UTC)
Posts: 13
Man
Netherlands
Location: Daarlerveen

Thanks: 4 times
Was thanked: 7 time(s) in 1 post(s)
So based on 2 programs above from Doggy,

I made a Video player time left title display that you can add on top of the Clock source by using the Multiview to stack upon.

While the code is not 100% perfect yet and only displays MM;SS But it gives you some idea and it's workable.

Till 60 seconds it's green, Turns then orange, and the last 10 seconds it's red.

Code:
' Checking time left of active running video and display this as an title. 
' and do some stuff at certain time remaining

dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Timeleft as double = 0
dim triggertime as integer = 10      '10 seconds before end
dim triggerduration as integer = 2000   'fade duration, could be different than trigger

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

'used at debugging stage
  ' console.writeline(Timingleft)
  ' console.writeline(Seconds)

dim ThisTime as string 
ThisTime = Minutes.ToString("00") + ":" + Seconds.ToString("00")


if Timingleft < 60
   'put a response in a title and change color accordingly
  
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=Timingleft) ' Value:=":", Value:=Seconds)
   
    if Timingleft < 30 
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="red")
    else
       API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="orange")
    end if  
else
    API.Function("SetText",Input:="Text Middle Centre Outline.gtzip",SelectedIndex:="0" ,Value:=ThisTime)
    API.Function("SetTextColour",Input:="Text Middle Centre Outline.gtzip",Value:="green")
 end if


sleep(50)
Loop
thanks 7 users thanked Xtreemtec Media for this useful post.
doggy on 4/10/2020(UTC), stigaard on 4/16/2020(UTC), deluna on 5/14/2020(UTC), dmwkr on 5/22/2020(UTC), studiodelta on 4/13/2021(UTC), jpetrie on 12/30/2021(UTC), nikosman88 on 2/4/2023(UTC)
doggy  
#18 Posted : Thursday, April 23, 2020 3:01:21 AM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Trigger a function at specific time of day


Code:
'Trigger a function at a specific time of day 

dim triggertime as string = "06:56"

'console.writeline ( DateTime.Now.ToString("hh:mm"))

Do While True
     If triggertime = DateTime.Now.ToString("hh:mm") Then
          ' The times match so do something like
           API.Function("OverlayInput1In",Input:="1")  'replace 1 with the to overlay input nr
          ' And we are done
           Exit do

     End If
     sleep(1000)
Loop


EDIT: change hh:mm to HH:mm for 24hr clock
thanks 7 users thanked doggy for this useful post.
dmwkr on 4/23/2020(UTC), Xtreemtec Media on 5/4/2020(UTC), studiodelta on 4/12/2021(UTC), WaltG12 on 9/14/2021(UTC), jcw718 on 11/9/2021(UTC), nikosman88 on 4/27/2022(UTC), Video-Chopper on 10/18/2023(UTC)
streaming---pro  
#19 Posted : Saturday, May 23, 2020 6:54:36 PM(UTC)
streaming---pro

Rank: Member

Groups: Registered
Joined: 5/15/2020(UTC)
Posts: 27
Germany

Hi everyone,

I'm really stuck on a little script that I wrote to fade in/out an input with the alpha value.

Unfortunately the API command doesn't get executed as soon as I put it inside a For next loop. What am I doing wrong here?


Code:

for i as integer = 255 to 0
API.Function ("SetAlpha",Input:=2,Value:=i)
i=i-1
next


If I comment the for/next loop out the API.Function works.

Any hint?

Thanks for your help!
doggy  
#20 Posted : Saturday, May 23, 2020 7:05:11 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,188
Belgium
Location: Belgium

Thanks: 288 times
Was thanked: 947 time(s) in 782 post(s)
Originally Posted by: streaming---pro Go to Quoted Post
Hi everyone,

I'm really stuck on a little script that I wrote to fade in/out an input with the alpha value.

Unfortunately the API command doesn't get executed as soon as I put it inside a For next loop. What am I doing wrong here?


Code:

for i as integer = 255 to 0
API.Function ("SetAlpha",Input:=2,Value:=i)
i=i-1
next


If I comment the for/next loop out the API.Function works.

Any hint?

Thanks for your help!


For next has to go up unless you tell it to step down!
and changing the i value within the loop is not a good idea as the loop already does that

Google "for loops counting down" for the solution
Users browsing this topic
26 Pages123>»
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.