logo

Live Production Software Forums


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

Notification

Icon
Error

Options
Go to last post Go to first unread
VideoE  
#1 Posted : Tuesday, February 15, 2022 4:36:23 AM(UTC)
VideoE

Rank: Advanced Member

Groups: Registered
Joined: 5/31/2020(UTC)
Posts: 49
United States
Location: California

Is there a way with web scripting to MarkOut a clip at a certain time value before the final end of the movie? I'm trying to mimic the 'Go To 30' buttons in Playback Pro which is a great way to to shorten rehearsal time by skipping to the last 30 sec.s of a long clip. In the shortcut reference I'm not seeing a clip duration to subtract time from.
Peter1000  
#2 Posted : Tuesday, February 15, 2022 8:17:19 AM(UTC)
Peter1000

Rank: Advanced Member

Groups: Registered
Joined: 1/25/2019(UTC)
Posts: 302
Switzerland

Thanks: 17 times
Was thanked: 79 time(s) in 60 post(s)
Code:
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-19999) )

sleep(500)

change the value 19999 for another time, 1000 = 1 second
VideoE  
#3 Posted : Tuesday, February 15, 2022 12:03:13 PM(UTC)
VideoE

Rank: Advanced Member

Groups: Registered
Joined: 5/31/2020(UTC)
Posts: 49
United States
Location: California

Thanks Peter for the script. I guess I will need to dive into vb.net scripting as I cannot parse what you are doing here... Are 'dim's a kind of variable declaration? And part of this is declaring this is an .xml doc that is a script and should be loaded?
doggy  
#4 Posted : Tuesday, February 15, 2022 5:57:14 PM(UTC)
doggy

Rank: Advanced Member

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

Thanks: 291 times
Was thanked: 955 time(s) in 790 post(s)
VideoE  
#5 Posted : Thursday, February 17, 2022 5:44:13 AM(UTC)
VideoE

Rank: Advanced Member

Groups: Registered
Joined: 5/31/2020(UTC)
Posts: 49
United States
Location: California

Thanks doggy, but I think I'm looking for something different. Imagine working with a producer in tech rehearsals and they want to run through a bunch of transitions including the playback movies. And imagine the movies are a few minutes apiece. So you play the first few seconds of the movie and the producer says 'can you go to the 20 or 30 seconds of the video' i.e. skipping the middle bits, to save rehearsal time. You could approximate with the scrubber bar but it would be nice to press a button that gave you the last 20 or 30 seconds exactly. It's an option in Playback Pro which is currently an industry standard for live shows. It would be nice to add to VMix as well as a script, and as I mentioned to Peter it would be so nice to do in Web Scripting but apparently I do have to learn vb.net scripting which is not currently approachable to someone just tackling the basics of Python. Oh Well.
Again Thanks
Eric
Roy Sinclair  
#6 Posted : Thursday, February 17, 2022 8:15:58 AM(UTC)
Roy Sinclair

Rank: Advanced Member

Groups: Registered
Joined: 11/23/2020(UTC)
Posts: 170
United States
Location: Wichita

Thanks: 10 times
Was thanked: 24 time(s) in 20 post(s)
Originally Posted by: VideoE Go to Quoted Post
Thanks doggy, but I think I'm looking for something different. Imagine working with a producer in tech rehearsals and they want to run through a bunch of transitions including the playback movies. And imagine the movies are a few minutes apiece. So you play the first few seconds of the movie and the producer says 'can you go to the 20 or 30 seconds of the video' i.e. skipping the middle bits, to save rehearsal time. You could approximate with the scrubber bar but it would be nice to press a button that gave you the last 20 or 30 seconds exactly. It's an option in Playback Pro which is currently an industry standard for live shows. It would be nice to add to VMix as well as a script, and as I mentioned to Peter it would be so nice to do in Web Scripting but apparently I do have to learn vb.net scripting which is not currently approachable to someone just tackling the basics of Python. Oh Well.
Again Thanks
Eric


Actually that script he gave you could be set to run when you push a button on an X-Keys device or even a specific key on the keyboard, it will set the current point of the current playing video to exactly 20 seconds before it's end.


And yes, DIM is how you declare a variable in VB. Let me break down that simple script for you:

Code:
' Set up two string variables, one to get the number of the active input and one for the duration of the video in milliseconds
dim duration as string = ""
dim activeinput as string = ""

   dim xml as string = API.XML()   ' Create one more string variable to receive the state of vMix which will be an XML document, then load it using the API.XML() call
   dim x as new system.xml.xmldocument   '  Create an XML document object to allow elements of the xml document to be searched
   x.loadxml(xml)   ' Load the XML into the XML document object

activeinput = (x.SelectSingleNode("//active").InnerText)    '  This XML search finds the <active> element of the XML and stores the InnerText of that element in the "activeinput" string
duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)  ' This XML finds the input element which is active in vMix and then extracts the value of the "duraction" property of that element.

API.Function("SetPosition",Input:=activeinput ,Value:=(duration-19999) )   ' This API function call sets the current position of the video to be 20,000 milliseconds before the end of the video.

sleep(500) '  This keeps you from triggering the script a second time if you hit the key twice within the same half second.

' Note that this will do nothing for any input that doesn't have "duration" so it will work for video and audio playback inputs but not cameras or static inputs like images 
VideoE  
#7 Posted : Sunday, February 20, 2022 8:18:05 AM(UTC)
VideoE

Rank: Advanced Member

Groups: Registered
Joined: 5/31/2020(UTC)
Posts: 49
United States
Location: California

WOW!. Roy, I am still working a show, long hours etc. Just saw this now, Sat. afternoon. Can't spend time with it, but in a few days I'll pore over it and start to learn. It just seems so different than Python... But this will help. So THANK YOU for taking the time.
Eric
Roy Sinclair  
#8 Posted : Monday, February 21, 2022 12:24:43 AM(UTC)
Roy Sinclair

Rank: Advanced Member

Groups: Registered
Joined: 11/23/2020(UTC)
Posts: 170
United States
Location: Wichita

Thanks: 10 times
Was thanked: 24 time(s) in 20 post(s)
Originally Posted by: VideoE Go to Quoted Post
WOW!. Roy, I am still working a show, long hours etc. Just saw this now, Sat. afternoon. Can't spend time with it, but in a few days I'll pore over it and start to learn. It just seems so different than Python... But this will help. So THANK YOU for taking the time.
Eric


Yep, you learn when you have time to learn :).

Note that the scripting in vMix has some serious deficiencies due to a very incomplete implementation, it lacks Functions so anything you need more than once you have to code more than once.

I suspect that was done to keep the script from being too intrusive in the vMix running environment.

However, it also includes the full DOT.NET (3.5?) API which is where the XML handling object used in the script came from. That also means you have all the database access functions available as well.

And if you are a new coder, try to code with excessive comments on what you think you are doing as opposed to writing blocks of code with no comments. You'll thank yourself years later when you don't have to wonder what on earth were you thinking when you wrote that and why was it written that way. That's regardless of what language you write in.





Kristoph  
#9 Posted : Monday, February 21, 2022 10:13:02 PM(UTC)
Kristoph

Rank: Member

Groups: Registered
Joined: 7/6/2020(UTC)
Posts: 15
United Kingdom

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
Here you go.

Change 'Secs' variable to adjust the time you want to jump to this is written in ms so 20000 (ms) for 20 seconds e.g. for 30 seconds use 30000

This script also takes into account the markout value.


Code:


dim position as string = ""
dim duration as string = ""
dim activeinput as string = ""
dim Secs as Integer = 20000
dim newPosition as double = 0

'Mark Out var

dim markOut as string = ""
dim mO as boolean = True

'load the vMix XML

dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)

'Add info to var

activeinput = (x.SelectSingleNode("//active").InnerText)
position = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@position").Value)


'Does mark out exist?

try
markOut = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@markOut").Value)
Catch e as Exception
mO = False
end try


'Set position to 30 secs left

if mO= True then
newPosition = Double.Parse(markOut) - Double.Parse(Secs)
API.Function("SetPosition",Input:= activeinput,Value:=newPosition)

   else if mO = False then
                 duration = (x.SelectSingleNode("//input[@number='"& activeinput &"']/@duration").Value)
                 newPosition = Double.Parse(duration) - Double.Parse(Secs)
                 API.Function("SetPosition",Input:= activeinput,Value:=newPosition)
                 end If
thanks 1 user thanked Kristoph for this useful post.
doggy on 2/22/2022(UTC)
Users browsing this topic
Guest (3)
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.