Resource icon

Scene Execute Command 1.1.0

mattbatt

Member
OK so I was testing this out and then I got distracted by the laptop which started hanging so I spent all day trying to figure that out. It wasn't your software it seems to be something to do with having VLC open full screen. It's been stable now for a while but not sure what fixed it.
 

wasdvd

New Member
This seems very useful for my situation. However, in my ignorance, I do not know how to assign SCENE_VALUE for each scene. Please advise. The instructions almost sound like there are check boxes and a value area for each scene. I cannot find it.
 

mattbatt

Member
When you are filling in the command and the values the check box to enable them is right above the scene name and value box.
1594227151715.png
 

Marq

New Member
This seems very useful for my situation. However, in my ignorance, I do not know how to assign SCENE_VALUE for each scene. Please advise. The instructions almost sound like there are check boxes and a value area for each scene. I cannot find it.
If the options per scene are not there, that is probably because you added the scenes after loading the script. You can use the `Reload scripts` button to reload the script, which will add the missing options.
 
I am running Windows 10, OBS 25.0.8, obs-scene-execute-command-script-1.0.1 connected to a Datavideo PTC-140 camera (firmware: camera 2.6.2, MCU 2.5.5, AF 4.0.6). After a bit of fiddling with the curl captured by Chrome (remove ^+newline and make a single command line), this worked for us - almost (see below).

curl "http://192.168.5.163/ajaxcom" -H "Connection: keep-alive" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "X-Requested-With: XMLHttpRequest" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Origin: http://192.168.5.163" -H "Referer: http://192.168.5.163/pages/live.asp" -H "Accept-Language: en-US,en;q=0.9" -H "Cookie: updateTips=true; language=en; LoginResult=false; -goahead-session-=::webs.session::c1e71319c63d813d9f8fb4286334e66f" --data-raw "szCmd=%7B%22SysCtrl%22%3A%7B%22PtzCtrl%22%3A%7B%22nChanel%22%3A0%2C%22szPtzCmd%22%3A%22preset_call%22%2C%22byValue%22%3ASCENE_VALUE%7D%7D%7D"

The lua script executes on OBS_FRONTEND_EVENT_SCENE_CHANGED which is sent when the scene transition is OVER. We are trying to run a 3 second 'stinger' to obscure the camera while it is moving to the new preset. Today we do that manually, we start the transition on OBS and then immediately start the camera move via web interface or IR remote. Looking at the OBS Studio Frontend API, there does not seem to be a signal sent from the frontend when the transition starts.
 

Alfredo Tudela

New Member
Good afternoon Marq.
Excellent work you have done !!!
I've been fighting all afternoon with your files :-) and now I've realized a theme. Can I run the script when the preview loads?
Vmix has a ptz module with these controls and I am considering switching to this software since I find it very interesting to preload the position of the ptz camera before making the transition.

I have a streamdeck the cat 32 buttons. I could use your scripts with this gadet as a previous one.

I have managed to move the camera from one preset to another from the browser console and I have downloaded your software from github but I don't know how to continue.
You help me?
User and password Admin - Admin
At the end of the command there is a 3A2 which is what changes and where 2 is the preset.
3A1, 3A2, 3A3
curl "http://192.168.1.153/ajaxcom" -H "Usuario-Agente: Mozilla / 5.0 (Windows NT 10.0; Win64; x64; rv: 79.0) Gecko / 20100101 Firefox / 79.0" -H "Aceptar: application / json , texto / javascript, * / *; q = 0.01 "-H" Aceptar-Idioma: es-ES, es; q = 0.8, en-US; q = 0.5, en; q = 0.3 "--comprimido -H" Referer: http://192.168.1.153/pages/live.asp "-H" Content-Type: application / x-www-form-urlencoded; charset = UTF-8 "-H" X-Requested-With: XMLHttpRequest " -H "Origen: http://192.168.1.153" -H "Conexión: keep-alive" -H "Cookie: language = en; updateTips = true; LoginResult = false; -goahead-session - = :: webs.session :: 5a3c8b6ad0f6a2143c20680cbafb9ede "--data-raw" szCmd = "%" 7B "%" 22SysCtrl "%" 22 "%"3A "%" 7B "%" 22PtzCtrl "%" 22 "%" 3A "%" 7B "%" 22nChanel "%" 22 "%" 3A0 "%" 2C "%" 22szPtzCmd "%" 22 "%" 3A " % "22preset_call"% "22"% "2C"% "22byValue"% "22"% "3A2"% "7D"% "7D"% "7D"
 

ms2oo8

New Member
I just purchased a Minrray PYZ and have the exact same problem as Alfredo.

My curl query isexactly the same. How do I remove the scene preset from the URL, so I can add it into the Scene Value Field of the script in OBS studio?

curl "http://192.168.1.40/ajaxcom" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "X-Requested-With: XMLHttpRequest" -H "Origin: http://192.168.1.40" -H "Connection: keep-alive" -H "Referer: http://192.168.1.40/pages/live.asp" -H "Cookie: language=en; updateTips=true; LoginResult=false; -goahead-session-=::webs.session::bfc9443179fb74b8cd949faf6d4a170f" --data-raw "szCmd="%"7B"%"22SysCtrl"%"22"%"3A"%"7B"%"22PtzCtrl"%"22"%"3A"%"7B"%"22nChanel"%"22"%"3A0"%"2C"%"22szPtzCmd"%"22"%"3A"%"22preset_call"%"22"%"2C"%"22byValue"%"22"%"3A1"%"7D"%"7D"%"7D"
 

ms2oo8

New Member
for UV510 Minrray PTZ the following value is used for the OBS command in the script

c:\cygwin64\bin\curl.exe "http://192.168.1.40/ajaxcom" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Accept-Language: en-US,en;q=0.5" --compressed -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "X-Requested-With: XMLHttpRequest" -H "Origin: http://192.168.1.40" -H "Connection: keep-alive" -H "Referer: http://192.168.1.40/pages/live.asp" -H "Cookie: language=en; updateTips=true; LoginResult=false; -goahead-session-=::webs.session::ace7df6c4bb9e656dcf0b14dd9afcfd8" --data-raw "szCmd="%"7B"%"22SysCtrl"%"22"%"3A"%"7B"%"22PtzCtrl"%"22"%"3A"%"7B"%"22nChanel"%"22"%"3A0"%"2C"%"22szPtzCmd"%"22"%"3A"%"22preset_call"%"22"%"2C"%"22byValue"%"22"%"SCENE_VALUE"%"7D"%"7D"%"7D"

then your presets are placed in the OBS scene value, they'll be 3A0, 3A1, 3A2 like the screenshot below

Instructions for Curl.
This command works for Windows 10, where Cygwin is installed for using Curl. WIndows 10 helpfully includes Curl, but doesn't include the --compressed option, so you need to install a Curl version that does, or use a real OS like Linux or Mac. Then set Cygwin in your Windows 10 path environment to be the first so your Cygwin Perl takes precendence in your Windows 10 command line over the version installed in Windows like so. Set the PATH variable to predend C:\cygwin64\bin\; to whatever is there so it is like following C:\cygwin64\bin\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps


The downside to this whole setup is that the script moves the camera, when the scene is activated, so in your broadcast, you'll see the moving camera. I think a better way would be to have your two cameras and simply use the curl commands to move the cameras in place prior to switching to the scene so you don't see the movement in the broadcast.

obs.jpg
 
Last edited:

arthurya

New Member
Marq ... this is a very helpful resource; thank you for posting and sharing. I have been able to get it to work, but it flashes a dialog box when the script goes to run. I had this behavior when I was doing things from my StreamDeck, but I was able to get around that flash be wrapping my PowerShell script in a vbs shell command (see below).

Is there a way to call commands or tweak the script so that there is no popup/flash when the code executes?

Thanks
Arthur

command = "powershell.exe -nologo -File C:\Users\canuc\OneDrive\Documents\Code\GetScores.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0
 

AEffigy

New Member
Hello, I am a theatre person using OBS for Zoom productions. I believe this plugin is the key to me being able to have hotkey presses when I fire a scene, but I do not know the coding language. Can someone help me out? I just need a script to press one button or button combination when each scene activates. Thanks for any help in advance!
 
@Marq --

I have the same question about the black command window that pops up when executing a command.

For me, the window pops up on the same screen I am recording -- makes for a not-so-pleasant result.

Is disabling it, or at least controlling it to only appear on the window that OBS is on, something that can be fixed, please?

FYI: I am wanting to use it to run a utility I created that will toggle the status of the Advanced Scene Switcher.
 

Knatteanka

New Member

Knatteanka

New Member
@Marq --

Is there a way to create a version of the script that executes a command when a scene is disabled (exited)?
How is it only checkbox for when inactivated or also value?
both can be done. But will be allot of info if you go for both checkbox and value.
but then a uniq value is possible for activation and deactivation
 

Knatteanka

New Member
Have uploaded my fork to a version that has enable box if it should trigger when activated or deactivated
if owner likes the fork it can be pulled in to the main.
 

Profile

New Member
Marq submitted a new resource:

Scene Execute Command - Script that can execute CLI command
OBS script for executing any CLI command whenever whenever a scene is activated. Useful for:
  • Loading a preset of any PTZ camera when an OBS scene is activated.
  • Executing any command that does anything when an OBS scene is activated.
Read more about this resource...

I have two PTZ cameras and can control both with this plugin, very nice!
But this script runs when an OBS scene is activated, so i see the preset change in the 'Program' screen (Live).
Is it posible to execute the commands by selecting a scene in the Preview , so i see the preset change in the 'Preview' screen?
That would be very nice!!
 

Knatteanka

New Member
I have two PTZ cameras and can control both with this plugin, very nice!
But this script runs when an OBS scene is activated, so i see the preset change in the 'Program' screen (Live).
Is it posible to execute the commands by selecting a scene in the Preview , so i see the preset change in the 'Preview' screen?
That would be very nice!!
try my fork and see if that does what you want :) and plz come with feedback.

it has 3 parts added to it:
1: checkbox to send command when scene is deactivated and not only when activated.(affect both live and preview)
2: Sepparate list for triggering when preview changed
3: changed the Decription to use HTML code and added sliders as linebreaks between setting groups.

What i use my forked script for is to send command to a ESP32 that i use as a Joystick when preview is changed to select that camera
and when live/Preview is changed send that information to work in progress Tally light.
 

John A

New Member
try my fork and see if that does what you want :) and plz come with feedback.

it has 3 parts added to it:
1: checkbox to send command when scene is deactivated and not only when activated.(affect both live and preview)
2: Sepparate list for triggering when preview changed
3: changed the Decription to use HTML code and added sliders as linebreaks between setting groups.

What i use my forked script for is to send command to a ESP32 that i use as a Joystick when preview is changed to select that camera
and when live/Preview is changed send that information to work in progress Tally light.

Thanks so much for this. It works well. I use it to execute a python script which sends VISCA commands to PTZ cameras when a scene goes into preview. These are typically calling a preset position and turning on/off a tally light on the camera when that scene goes live. The first can be done using HTTP but the second requires VISCA on my PTZoptics cameras. I do see a flash of a terminal window for a brief moment when the script calls the python program but that does not appear in the recording so it's not a big deal. Thanks again!
 
Top