marklagendijk / obs-scene-execute-command-script

OBS script for executing any CLI command whenever whenever a scene is activated
MIT License
28 stars 6 forks source link

Script executes on MS-DOS but not on OBS #1

Closed St-Philip-Lutheran closed 4 years ago

St-Philip-Lutheran commented 4 years ago

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).

My issue is that a command from DOS moves the camera. The identical command from obs-scene-execute-command-script via OBS does not.

My command is: 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"

It does look like SCENE_VALUE is being substituted properly. When I change a scene in OBS requiring a preset change, the script log says go to preset 9 as expected. [scene_execute_command.lua] Activating cs8 Camera only. Executing command: [scene_execute_command.lua] curl "http://192.168.5.163/ajaxcom" ^ [scene_execute_command.lua] -H "Connection: keep-alive" ^ [scene_execute_command.lua] -H "Accept: application/json, text/javascript, /; q=0.01" ^ [scene_execute_command.lua] -H "X-Requested-With: XMLHttpRequest" ^ [scene_execute_command.lua] -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" ^ [scene_execute_command.lua] -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" ^ [scene_execute_command.lua] -H "Origin: http://192.168.5.163" ^ [scene_execute_command.lua] -H "Referer: http://192.168.5.163/pages/live.asp" ^ [scene_execute_command.lua] -H "Accept-Language: en-US,en;q=0.9" ^ [scene_execute_command.lua] -H "Cookie: updateTips=true; language=en; LoginResult=false; -goahead-session-=::webs.session::c1e71319c63d813d9f8fb4286334e66f" ^ [scene_execute_command.lua] --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%3A9%7D%7D%7D"

When I run this identical command on DOS box, the camera moves to preset 9 and I see a good return value. C:\Users\User>curl "http://192.168.5.163/ajaxcom" ^ More? -H "Connection: keep-alive" ^ More? -H "Accept: application/json, text/javascript, /; q=0.01" ^ More? -H "X-Requested-With: XMLHttpRequest" ^ More? -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" ^ More? -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" ^ More? -H "Origin: http://192.168.5.163" ^ More? -H "Referer: http://192.168.5.163/pages/live.asp" ^ More? -H "Accept-Language: en-US,en;q=0.9" ^ More? -H "Cookie: updateTips=true; language=en; LoginResult=false; -goahead-session-=::webs.session::c1e71319c63d813d9f8fb4286334e66f" ^ More? --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%3A9%7D%7D%7D" {"nRetVal":0, "szError":""}

I do not see that return information in the script log. That is, {"nRetVal":0, "szError":""}. Looking at the source this appears to be expected.

I have tried resyncing the script. I have reinstalled the script.

Thanks in advance for any help you might be able to provide.

marklagendijk commented 4 years ago

Try the following:

  1. Use double quotes instead of single quotes. If you need to have double quotes in the values escape them with a \.
  2. Don't use ^ + newlines, instead just make the whole command one big line.
St-Philip-Lutheran commented 4 years ago

Thank you, I removed ^ + newlines and it worked - almost. 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 by asking the volunteer to 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.

Of course, this issue can be closed with my thanks. Do you, by chance, know of anyone or any work being considered to add a new OBS Studio Frontend API signal?