# Control Visca-over-IP based cameras



## vwout (Jan 1, 2021)

vwout submitted a new resource:

Control Visca-over-IP based cameras - This script adds a source to a scene in OBS which can be used to control a camera.



> This plugin adds a source to a scene in OBS. With this source, a camera can be controlled. Its main purpose is to automatically switch a camera to a certain preset when the scene is activated. This activation can be as soon as the scene is active in preview, in program, or both.
> 
> Besides recalling a pre-made preset, this plugin supports a few more control operations:
> 
> ...



Read more about this resource...


----------



## ghostman90215 (Jan 6, 2021)

This is spot-on wha I’m looking for, and inferring from the examples... for the same reasons... PSZ camera steering based on scene selection for worship services so that the stream producer can automate camera control without the need for a person separately running the cameras.

I downloaded and installed this last night. I have not been able to get it to work. Is there a troubleshooting protocol someone could point me at?


----------



## Lawrence_SoCal (Jan 7, 2021)

Sorry, for new folks to OBS, the following installation instructions may not be clear:



> The plugin is a script plugin and utilizes the Lua scripting capabilities of OBS. To use the plugin, add the file _obs-visca-control.lua_ to OBS under _Script_ in the _Tools_ menu. The other _.lua_ files in this repository are also required, but should not be added as scripts in OBS.



the 3 *.lua files in the download ZIP, being

libvisca.lua Cleanup
ljsocket.lua Add Visca library with support for Power On/Off and Preset Recall
obs-visca-control.lua Release v1.0
The first 2 of those, being the "other" files referenced. And all 3 files need to go into the same directory, right?

Is the following accurate (for fresh Win10 x64 OS, 64-bit OBS install) /common practice
Copy those 3 files into either
   C:\Program Files\obs-studio\data\obs-scripting\64bit
  or would it be
   C:\Program Files\obs-studio\data\obs-plugins\frontend-tools\scripts
   or does it not matter? _[sorry, showing my obvious ignorance on this matter]_

Then


> To use the plugin, add the file _obs-visca-control.lua_ to OBS under _Script_ in the _Tools_ menu


that is, in OBS, click on Tool-> Scripts then click the "+" symbol, and point to _obs-visca-control.lua and Click OK ??_


----------



## vwout (Jan 7, 2021)

ghostman90215 said:


> I downloaded and installed this last night. I have not been able to get it to work. Is there a troubleshooting protocol someone could point me at?


What you can do is open the script log from the scripts dialog. This might log failures or issues. To get more detailed logging, open obs-visca-control.lua and change line 18 to 'plugin_data.debug = true'. A reload of the plugin should start logging plenty of information.
When you don't see errors in the logs, it could be that your camera uses a Visca dialect that is slightly different from the 'standard'.


----------



## vwout (Jan 7, 2021)

Lawrence_SoCal said:


> The first 2 of those, being the "other" files referenced. And all 3 files need to go into the same directory, right?


That is correct.



> Is the following accurate (for fresh Win10 x64 OS, 64-bit OBS install) /common practice
> ...
> or does it not matter? _[sorry, showing my obvious ignorance on this matter]_


It does not matter where the 3 files are. These can be stored anywhere the directory obs-plugins\frontend-tools\scripts is a good place; the other location is for plugins and this is a script. But files can be anywhere on your machine.



> that is, in OBS, click on Tool-> Scripts then click the "+" symbol, and point to _obs-visca-control.lua and Click OK ??_


Correct.



> for new folks to OBS, the following installation instructions may not be clear:


I will make an attempt to improve the readme ;)


----------



## kmill243 (Jan 8, 2021)

Has anyone tried this with PTZOptics Cameras?


----------



## vwout (Jan 13, 2021)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.1



> This updated includes a few enhancements and minor changes to the documentation:
> 
> The visibility (enabled/disable) of the Visca plugin source is now respected. When the plugin is disabled in a scene, the action is not executed.
> A new options is added to the source settings of the plugin to run an action on preview only when the camera is not active on program. This prevents accidental changes to the camera as long as it is live for broadcasting.



Read the rest of this update entry...


----------



## btpwisconsin (Feb 9, 2021)

kmill243 said:


> Has anyone tried this with PTZOptics Cameras?


I am also trying to use this script with PTZOptics cameras. It appears to provide exactly the functionality I want (calling Preset positions only in Preview), but I cannot get it work. My PTZOptics camera states that the UDP port is 1259 rather than 52381. I tried changing the default UDP in the libvisca.lua file and then monitored the UDP traffic. It still appears to go out on UDP Port 52381. I tried to define the IP address using 192.169.x.x: 1259, but the Script didn't accept that. 

Is there a way to change the UDP port used to send these VISCA over IP commands through the script?

Thanks for this awesome script!


----------



## btpwisconsin (Feb 9, 2021)

btpwisconsin said:


> I am also trying to use this script with PTZOptics cameras. It appears to provide exactly the functionality I want (calling Preset positions only in Preview), but I cannot get it work. My PTZOptics camera states that the UDP port is 1259 rather than 52381. I tried changing the default UDP in the libvisca.lua file and then monitored the UDP traffic. It still appears to go out on UDP Port 52381. I tried to define the IP address using 192.169.x.x: 1259, but the Script didn't accept that.
> 
> Is there a way to change the UDP port used to send these VISCA over IP commands through the script?
> 
> Thanks for this awesome script!



 An update. I must have been editing the  libvisca.lua incorrectly at first. When I changed line 6 of this file to set the default port to 1259, it did result in UDP messages sent to the port that PTZOptics uses for Visca over IP. I cannot test this today as I need to get into my church to reconnect the cameras. But I'll try to report whether it works once I'm able to do that.


----------



## btpwisconsin (Feb 16, 2021)

btpwisconsin said:


> An update. I must have been editing the  libvisca.lua incorrectly at first. When I changed line 6 of this file to set the default port to 1259, it did result in UDP messages sent to the port that PTZOptics uses for Visca over IP. I cannot test this today as I need to get into my church to reconnect the cameras. But I'll try to report whether it works once I'm able to do that.


After getting back to this with connected PTZOptics cameras I do see UDP network traffic at the correct remote UDP port and IP address but my cameras do not respond to the Preset Recalls that I send :-(. No joy yet with PTZOptics Cams and this script


----------



## CyBeaer (Feb 17, 2021)

same here, tested with editing the libvisca.lua and changing the ports in the webinterface of the cameras.

Are all VISCA Protocoll Cameras supported or is there some exclusion?

Tested with the PTZOptics Camera NDI HS and the HuddleCamHD


----------



## vwout (Feb 17, 2021)

The plugin follows the Sony Visca protocol, but is only tested (by me) on NDI cameras from Everet.
The command that is used to recall a memory preset is equal for these cameras (according this PTZOptics source: https://ptzoptics.com/wp-content/uploads/2014/09/PTZOptics-VISCA-over-IP-Commands-Rev1_0-5-18.pdf).

@btpwisconsin Would you mind sharing your network capture? The camera might respond with an error code.


----------



## vwout (Feb 18, 2021)

After taking a closer look to the PTZOptics specification, it looks like their Visca implementation only supports 'commands' and therefore does not use the Visca message header.  You can test this hypothesis by replacing lines 64-77 in libvisca.lua by the single line 
local data = self.payload


----------



## vwout (Feb 19, 2021)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.2



> This updated improves the Visca implementation:
> 
> Fix for a resource leak; socket connections were not closed, claiming a new connection for every send command.
> Connections are now re-used for each camera. This also means that the message counter (part of the Visca protocol header) is now used properly.



Read the rest of this update entry...


----------



## RolandW (Feb 26, 2021)

I'm happy to report that this works perfectly with our church's BZB Gear BG-UPTZ-12X camera. This will make training volunteers much easier. Thanks!


----------



## extrapolary (Mar 1, 2021)

I've been using this for a few weeks and it works great. However, the motion between presets can be jerky and rapid. Is there a way to control the movement speed?


----------



## vwout (Mar 6, 2021)

@extrapolary Thanks :). The support for movement speed depends on the camera. The plugin only requests the camera to recall a preset. The Visca protocol does not support setting a movement speed that should be applied for that specific recall. Movement speed could be part of the preset, but that is dependent on the implementation of presets by the camera.
At this moment, the plugin also does not know what the preset represents; it is not aware whether the preset is a zoom, a pan or a change in image settings


----------



## vwout (Mar 6, 2021)

Regarding the support of PTZOptics cameras: Is the anyone that has a PTZOptics camera and has the knowledge to make a network capture (Wireshark) so that I can try to make the plugin work with PTZOptics as well?


----------



## tjfoth (Apr 25, 2021)

I'll try to do that today.


----------



## tjfoth (Apr 25, 2021)

Here's a URL with a lot of documentation about the PTZOptics implementation of VISCA:
IP Control & Scripting for PTZOptics Cameras : PTZOptics Knowledge Base
I've attached the WireShark trace.  I haven't studied it or your code yet.


----------



## vwout (Apr 25, 2021)

Thanks. I will investigate it. At first glance it looks like PTZOptics does not want the message header that the Visca protocol specifies.


----------



## tjfoth (Apr 25, 2021)

Here's the pcapng file.


----------



## tjfoth (Apr 25, 2021)

The two python scripts listed here at the bottom of the page ("4cam...") actually recall presets using UDP.
IP Control & Scripting for PTZOptics Cameras : PTZOptics Knowledge Base


----------



## vwout (May 22, 2021)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.3



> New features for the script plugin: support for PTZOptics and Hotkey actions.
> 
> - PTZOptics support: The script settings have two new configuration items: the port and protocol mode. The port defaults to  52381 and can be changed when needed (e.g. to 1259 for a PTZOptics camera). The protocol needs to be set to 'PTZOptics' to make the script talk the Visca dialect of PTZOptics.
> - Pan, Tilt & Zoom actions can now be performed using a hotkey (for camera's that support pan, tilt or zoom). The...



Read the rest of this update entry...


----------



## tjfoth (May 22, 2021)

Used this at our church services last two Sundays and it was simply brilliant.  So much more reliable than using the whole URL approach.  Thanks so much for adding this!


----------



## Baron Oz (Jun 3, 2021)

I just purchased a SMTAV 30x PTZ camera that is supposed to be pretty much identical to its PTZOptics counterpart.  I've installed the plugin and configured it, but I'm not getting any camera motion when I switch to the scene with the VISCA Camera Control Source.  I have presets stored in the camera that I can switch to using the camera remote, I would assume that the digit in the script presets window corresponds to the preset number in the camera.
This looks like a great plugin, and is perfect for my needs.  I hope I can get it to work.   If anyone has any pointers on troubleshooting, I'd love to hear from you.  I can supply whatever data you need to look at.
Thanks!


----------



## vwout (Jun 3, 2021)

Can you share some detail on how you configured it, both the script settings and the scene source settings?
What could also help is the output of the script log (send it via a private message if you don't want to share it publicly).

A few points of attention:
- Does the camera support Visca over IP? A quick look on the specs only mentioned Visca over a serial connection (RS232/422/485)
- Is there a PC-tool from that manufacturer that does work via the network?
- Did you specify the correct IP address and port for this camera?
- Did you try both 'Generic' and 'PTZOptics' mode?


----------



## Lawrence_SoCal (Jun 4, 2021)

Baron Oz said:


> I just purchased a SMTAV 30x PTZ camera that is supposed to be pretty much identical to its PTZOptics counterpart.



Between SMTAV which then disappeared from Amazon to AVKANS, which appear to be hardware clones of PTZOptics
However, online reviews indicate the software of the two mentioned (at least) is sub-par at best. 
So my question - are these legit 'clones' or illegit? and for simple use cases the 1/2 price may be worth it. But if you want NDI, etc, then on-going firmware updates, and decently tested and operating s/w is important. And I haven't yet seen these knock-offs to be confirmed at that level. I'm streaming using a Panasonic 20x NDI camera. I'd love a 1/2 price option for some additional angles to cover a large room. But I'm waiting at the moment
Good Luck and I'll be watching to what king of vendor support you get, as well as getting interoperability with standards s/w


----------



## Baron Oz (Jun 5, 2021)

Got it working!  So cool!!!   
Can't wait to use it next week for my 4 camera live stream, what a game changer!
Thanks for writing this from the bottom of my heart :)


----------



## Heino Falcke (Jun 13, 2021)

Is that tool working with MacOS?  I installed in on a Mac (M1) for OBS v26&27 and used a Sony SRG-X400, but the camera doesn't respond. The OBS script log files tell me that the commands are issued and AFAIK all setting in the camera should be ok (at least I can send cgi-calls via OBS to the camera, but that has other problems in OBS, which doesn't refresh them and a script I have found to work around this, does not work with multiview. So, I am a bit stuck right now ).


----------



## vwout (Jun 13, 2021)

I actually don't know whether the low-level socket library works on MacOS. When the script does not show errors, it should work. The script uses a different connection method than cgi-calls, so these can't be directly compared. A quick look at the documentation seems to indicate that the camera supports Visca-over-IP using the exact protocol this script implements.
Are you familiar with using Wireshark? Could you create a capture of traffic between your machine and the camera while using the script?


----------



## Heino Falcke (Jun 24, 2021)

vwout said:


> I actually don't know whether the low-level socket library works on MacOS. When the script does not show errors, it should work. The script uses a different connection method than cgi-calls, so these can't be directly compared. A quick look at the documentation seems to indicate that the camera supports Visca-over-IP using the exact protocol this script implements.
> Are you familiar with using Wireshark? Could you create a capture of traffic between your machine and the camera while using the script?


 Yes, I used Wireshark and I saw that the port was invalid. I changed the port to 52380 , which was valid, and at some point the camera would actually move. However, when I restarted OBS and the camera, it wouldn't work at first, then changing ports (or whatever else I did), it would suddenly work again. Unfortunately, I could't really reliably reproduce that behavior or make any sense of it. So, I eventually gave up and wrote my own script using curl and cgi commands. That seems to work well now.


----------



## tmimlitch (Jul 24, 2021)

Thank you soooo much VWOUT!  This is just what I need.  I am in the process of transferring our live stream process to OBS and this will help immensely. 

i set up a few test scenes using two of my five Glow Stream cameras,  One of the cameras is responding correctly but the second one has a spasm ... it points backwards and shuts itself off whenever the script touches it.  I have to interrupt its ethernet (POE) connection for it to respond again.

Not asking for any help yet, as I need time to do some diagnostics, check myconfigurations and run other trials.  I'll get back to you.


----------



## vwout (Jul 24, 2021)

Hi tmimlitch, thanks, my pleasure :)

The reaction of the camera seems weird to me. To provide some help, a few more details would be of added value:
- which camera (brand, type) has issues?
- does it officially support Visca over IP?
- which mode are you using it in; Generic or PTZOptics?
- which version of the script are you using - latest I presume?


----------



## tmimlitch (Aug 9, 2021)

vwout said:


> Hi tmimlitch, thanks, my pleasure :)
> 
> The reaction of the camera seems weird to me. To provide some help, a few more details would be of added value:
> - which camera (brand, type) has issues?
> ...



Sorry for the delay, but I finally found my own problem, in the configuration of the camera, everything is working beautifully now.  Great software.

But I do have another question, is it possible to access these NDI cameras by name instead of IP address, as the IP sometimes changes with DHCP.


----------



## Lawrence_SoCal (Aug 9, 2021)

tmimlitch said:


> But I do have another question, is it possible to access these NDI cameras by name instead of IP address, as the IP sometimes changes with DHCP.


Yes, if you are running you own local DNS or similar name resolution service
But, realistically, if you are asking this question and having this issue, then most likely the solution will be more involved than simply setting the cameras to fixed (static) IPs, or the easiest may be to see if you can set up a DHCP reservation


----------



## markdj (Sep 4, 2021)

Our church has just got a ptz camera, looks very similar to ptz optics. I cannot get the script to recall the presets from the camera so I cant select the presets in the scene. What is interesting, if I add a scene switch with the preset blank, the camera does move to preset 1 so it is obviously connecting and receiving in some way.


----------



## vwout (Sep 6, 2021)

Hi markdj,
two questions:
- which brand/model of PTZ camera are you using
- how did you configure the script and presets
It would be helpful when you could share the log.


----------



## markdj (Sep 6, 2021)

The camera is this one.









						1098.1C$ 20% OFF|New Design 4k Uhd Local Storage Usb Sdi Hdmi 12x Zoom Ptz Conference Camera For Meeting Room - Conference System - AliExpress
					

Smarter Shopping, Better Living!  Aliexpress.com




					a.aliexpress.com
				




I added the lua files to the obs program folder and opened obs. I opened scripts, added the single lua file as per instructions and set up IP address and port. At this point, I'm guessing the presets should be recalled?? I also tried adding presets to this area but when I'm in scene mode, the drop down (after selecting preset tab) is blank, whether I have a preset saved in the scripts area or not.

I won't be at church till next Sunday but can try to get a log file then.


----------



## vwout (Sep 6, 2021)

When there are no presets listed in the drop-down in the scene source, the syntax that you used in the script settings is probably not correct. The plugin is not capable of retrieving presets stored in your camera. You will have to list them manually in the script settings, using the format that is in the readme at https://github.com/vwout/obs-visca-control


----------



## markdj (Sep 6, 2021)

vwout said:


> When there are no presets listed in the drop-down in the scene source, the syntax that you used in the script settings is probably not correct. The plugin is not capable of retrieving presets stored in your camera. You will have to list them manually in the script settings, using the format that is in the readme at https://github.com/vwout/obs-visca-control


Ah, I see what u mean now, I didn't realize the preset thing was like basic programming code. Thank you, this will be fun. I'll let you know how I get on.


----------



## Randle (Sep 7, 2021)

Have you looked at collaborating with this project. It would be incredibly valuable
PTZ Controls | OBS Forums (obsproject.com)


----------



## PCCSF (Sep 8, 2021)

Just got a new camera that supports Visca and it's been working fine once I get it running properly, however there seems to be a bug somewhere. I need some help getting the proper information to you to help troubleshoot. The bug is that after a reboot of the system, the recall presets seems to just stop.

What happens is if I delete all the instances of the preset commands in all my scenes, then re-add them, The script starts to work again. If I shutdown or reload OBS, randomly the presets are no longer being called.. I go through the process of deleting the "VISCA control" source one at a time through the scenes and eventually I will come across the one that seems to be hanging up the the recall script.. Then it will work fine as I add the script back into each scene that needs it. 

I have not totally documented it yet but from initial trials it seems to be pretty random, however the fix is always the same. Delete then re-add.

Using plug in Version 1.3
OBS Version 27.0.0 64 bit
Windows 10 Pro Version 20H2 Build 19042.1165
Hardware is Intel I7 8700 with 16GB Ram
Camera is AIDA PTZ-NDI-X20 (Per mfg uses PTZOptics emulation) with Firmware V1031 (latest)


Any help would be appreciated. 

Thank you.


----------



## vwout (Sep 8, 2021)

Randle said:


> Have you looked at collaborating with this project. It would be incredibly valuable
> PTZ Controls | OBS Forums (obsproject.com)


Yes, I did, but although this script also allows interactive control, its main purpose is to automate the control as part of a scene, so that the camera automatically changes position based on the scene. And because it is a script it works on all platforms ;)


----------



## vwout (Sep 8, 2021)

PCCSF said:


> What happens is if I delete all the instances of the preset commands in all my scenes, then re-add them, The script starts to work again. If I shutdown or reload OBS, randomly the presets are no longer being called.. I go through the process of deleting the "VISCA control" source one at a time through the scenes and eventually I will come across the one that seems to be hanging up the the recall script.. Then it will work fine as I add the script back into each scene that needs it.
> 
> Any help would be appreciated.


Thank you for the complete description including version information!

Could you try the following: after starting OBS, open the scripts dialog, select the script 'obs-visca-control.lua' and click the reload button under the scripts (the icon with the two rounded arrows).


----------



## PCCSF (Sep 12, 2021)

vwout said:


> Thank you for the complete description including version information!
> 
> Could you try the following: after starting OBS, open the scripts dialog, select the script 'obs-visca-control.lua' and click the reload button under the scripts (the icon with the two rounded arrows).



Yay That works. Is this a problem/bug with OBS or the plugin? 

I may need to implement this script / Process into a system I'm working on designing for a church where they do NOT have a tech or volunteer that is real tech savvy so I'm trying to make it as simple as possible. It will probably be a consideration if it's something that needs intervention randomly.

They need a system that they can turn on, and it works. I am going to implement using a streamdeck mini so they should be able to run most of their stream/worship with just a 6 button streamdeck and a computer. They already have an auto mixer for their in house sound system.


----------



## PCCSF (Sep 12, 2021)

and THANK YOU


----------



## vwout (Sep 12, 2021)

You are welcome ;)

Actually, I don't know whether the problem is in the script, or OBS loading stuff. I have seen the behavior before but I can't really explain it. Guess I'll have to do some deep-dive debug sessions ...
Other than that, your approach should work. We use the plugin in the same way at church.


----------



## vwout (Sep 24, 2021)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.4



> Stability fixes and new features for the script plugin: support Pan/Tilt and Zoom in scene actions.
> 
> This update adds new capabilities for animation actions in the scene configuration dialog (thanks to a user contribution by christinoleo). The actions Pan/Tilt, with configurable direction and speed, and Zoom, also with configurable speed, are now available as action in a scene.  This way you can pan the camera over a crowd automatically in a scene. When you switch scenes, the animation is...



Read the rest of this update entry...


----------



## enca1024 (Oct 1, 2021)

I'm using this to control a couple of Canon CR-N500s and it works very well.  I think I've come across one issue though - as per the Visca spec I've seen, the minimum tilt speed is 01 but you currently have 00 for Visca.limits.TILT_MIN_SPEED in libvisca.lua.  On my cameras, using 0 results in no movement at all so I believe this needs updating.


----------



## enca1024 (Oct 1, 2021)

Also, I've modified your script to add support for PRESET DRIVE SPEED for Preset Recall as well as reworking the Zoom function slightly to have a single Zoom action with the directions as a parameter which includes Stop as one of those directions.  This makes it more closely aligned with the Pan/Tilt action and having the Stop option works much better for my use case.

Both of these need a bit of tidy up right now but I'd be happy to either share what I've done so far or do some tidy up and share if it's of use.


----------



## vwout (Oct 1, 2021)

Thanks for pointing out that bug. It is resolved in the latest commit on Github.
Regarding the other changes, I'd be happy to integrate those changes. I am curious how you handle the zoom Stop command in relation to deactivation of a scene. When a zoom action is executed, deactivating the scene, will stop the zoom (if the camera is no longer active). Are you applying it in scenes that use the same camera source, to start/stop zooming triggered by a scene?


----------



## enca1024 (Oct 2, 2021)

Thanks for fixing the bug so quickly!

In terms of the zoom Stop command, I've left the deactivation of the scene as is.  I've simply combined the Zoom In and Zoom Out actions into one Zoom action which has "Directions".  Those Directions pull the values from Visca.Zoom_subcommand, in the same way that the PanTilt Directions come from Visca.PanTilt_directions.  I've then introduced a connection.Cam_Zoom(subcommand, speed) function in libvisca.lua which forwards to the appropriate existing Zoom function.

For my use case, I'd like to be able to stop a zoom with the camera still active.  The way I've done it is to have various scenes in OBS which include the camera plus the appropriate Visca Camera Control PanTilt or Zoom direction.  One of the scenes is a "Stop" command which also includes the camera as a source and uses two Visca Camera Control sources to stop both the PanTilt and Zoom.  With an Elgato StreamDeck I can then have direction and zoom buttons for a camera which kick-off smooth slow pans and/or zooms when live with a stop button to stop the movement when appropriate.

I'll aim to do some tidy up of the code over the next few days and send it over.


----------



## enca1024 (Oct 12, 2021)

I've modified the checked in scripts from yesterday (11th Oct) with the updated zoom code to make it more consistent with Pan/Tilt and included a Zoom Stop command.  See attached .txts (renamed from .lua).  They now do the following:

- Merge Zoom In and Zoom Out into one Zoom action
- Add a Zoom/Stop command
- Update the Zoom Speed slider under properties (when the Zoom action is selected) to go from 0-7 as per the Visca spec.

I've tested it in OBS using a Visca Control Source but haven't tested the hotkeys or deactivating a scene, although I believe I've made the relevant updates.

If you're ok with this, I can factor in the Preset Drive Speed too.


----------



## PCCSF (Oct 13, 2021)

vwout said:


> vwout updated Control Visca-over-IP based cameras with a new update entry:
> 
> Release 1.4
> 
> ...


FYI this did not fix my symptom (needing to reload the script every time we start OBS) but the addition of the speeds of PTZ is a very nice addition. Less dizzying if we have to move the camera while the camera is visible.


----------



## howieb (Oct 22, 2021)

PCCSF said:


> FYI this did not fix my symptom (needing to reload the script every time we start OBS) but the addition of the speeds of PTZ is a very nice addition. Less dizzying if we have to move the camera while the camera is visible.


 I'm having the same problem you are... Just stops working.  I'll have to try this tomorrow (reloading the script).  I've tried everything but that.  If it works for me I'll be very pleased (and I'd love to get the root cause and issue fixed).


----------



## mab42 (Nov 3, 2021)

Same here - need to reload the script after each start of OBS to make it working with a BirdDog P200.

Oh, and almost forgot: Thank you very much indeed for making this available. If we can get rid of the reload issue, this will be a core element of our system to quickly power up, load some presets and afterwards power down. Very much appreciated!


----------



## vwout (Nov 3, 2021)

Thanks for all the heads up. I'm puzzled why the reload is required. I did some debugging but unfortunately did not find the root cause yet. I will spend some more time with OBS, my Lua editor, and Wireshark.


----------



## vwout (Nov 7, 2021)

@mab42, @howieb, @PCCSF: I found the root cause of the issue at startup of OBS.
It is related to the initialization of defaults.

It occurs when the Visca port is not modified during configuration but left to its default value. You can work around it by manually adjusting the port and setting it back to the default (52381).

This will be properly solved in the next release.


----------



## mab42 (Nov 8, 2021)

vwout said:


> @mab42, @howieb, @PCCSF: I found the root cause of the issue at startup of OBS.
> It is related to the initialization of defaults.
> 
> It occurs when the Visca port is not modified during configuration but left to its default value. You can work around it by manually adjusting the port and setting it back to the default (52381).
> ...


Great you found the cause... 
FWIW, I did enter my custom port in the script UI before. 
I just noticed a new version on github and tried it - seems to work fine now! :-)


----------



## jzee (Nov 8, 2021)

Baron Oz said:


> Got it working!  So cool!!!
> Can't wait to use it next week for my 4 camera live stream, what a game changer!
> Thanks for writing this from the bottom of my heart :)


Hey, I'm in a similar situation and couldn't get it to work with this camera either.
What did you end up doing to fix it?


----------



## PCCSF (Nov 15, 2021)

vwout said:


> @mab42, @howieb, @PCCSF: I found the root cause of the issue at startup of OBS.
> It is related to the initialization of defaults.
> 
> It occurs when the Visca port is not modified during configuration but left to its default value. You can work around it by manually adjusting the port and setting it back to the default (52381).
> ...


SWEEEEET..

That workaround fixed it!

Thank you....


----------



## vwout (Nov 28, 2021)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.5



> This release mainly contains changes and small enhancements under the hood.
> 
> It fixes one bug: when the Visca port was not modified in the settings, the initial connection failed when the scripts dialog was not opened. The connection is now always correctly setup at startup of OBS.



Read the rest of this update entry...


----------



## barryOBS (Dec 8, 2021)

I have a problem with the control of multiple cameras. When adding the first camera I can do everything with it, full control. When I add the next two cameras I can not pan or tilt, only zoom and adjust focus. It seems something is blocking the movements. Those two cameras also doesn't respond to the remote control anymore and I have to unplug the power to get contact with them with the remote. I use Visca over IP UDP Port 52831. The cameras are StoltzenArgos PTZ3000 . I have control over all three when I use a physical PTZ controller.


----------



## vwout (Dec 14, 2021)

Hi @barryOBS, can you share you configuration and a log file of a session?
You can get a log by enabling the checkbox 'Enable verbose logging' in the script settings. Open the log using the 'Script log' button and try using the camera's.


----------



## jbcurler2010 (Jan 21, 2022)

I'd love to be able to add more than 8 cameras.


----------



## vwout (Jan 22, 2022)

To increase the number of camera's that you can configure in the plugin, change the number '8' at position 95 of line 280 in the file 'obs-visca-control.lua' to something else: https://github.com/vwout/obs-visca-control/commit/fbcd19844ec38c3abcf9953e3267056a4a53295a


----------



## RolandW (Jan 22, 2022)

I've been using 1.2 successfully for some time now with our BZB Gear PTZ camera, but have not been able to get it to work with our B20SA. The latter does not have pan or tilt capability, but I would like to have scenes for various zoom levels. Most of this thread is way over my head. Is there anything obvious in the attached screenshot that gives you a clue? I am at home now so I don't have it in front of me. I intended to work on this earlier today, but while I was at church our flakey rural DSL connection went down so I had to call it a day. Thanks for providing this great tool!


----------



## vwout (Jan 23, 2022)

Hi RolandW, you are welcome :)

Your configuration looks correct at first glance. A quick scan of the user manual (https://bzbgear.com/wp-content/uploads/2020/manuals/BG-B20SA-manual.pdf) however seems to suggest two things:
- This specific camera model uses port 3001 (see chapter 4.2.6)
- It looks like this model uses the PTZ-Optics variant of the Visca protocol

In order to be able to set these, update the plugin to the latest version (1.5 at time of writing, see the download link). Version 1.3 and later allow configuration of the port (defaults to 52381 and may need to be changed to 3001) and the mode (may need to be changed to PTZ-Optics).
When testing, I suggest making these changes one at a time:
- Update the plugin, retest (no change expected)
- Change the port of the B20SA, retest (may already work)
- Change the mode to PTZ-Optics, retest
- In case it still does not work, leave the mode to PTZ-Optics and change the port back to 52381, retest


----------



## RolandW (Jan 23, 2022)

Wow, thank you for the quick diagnosis. I was actually getting ready to install 1.5 yesterday when internet and phone service went down for the whole neighborhood. I doubt I'll have time to do that before the service today but I hope to get back over there later in the week. Is updating just a matter of replacing obs-visca-control.lua with the new file? If I have a minute to spare this morning, I might try just changing the port to see what happens (sorry: I should have read the manual more thoroughly). I will report back!


----------



## vwout (Jan 23, 2022)

You will need to replace all the .lua files that are in the download.


----------



## RolandW (Jan 24, 2022)

vwout said:


> Hi RolandW, you are welcome :)
> 
> Your configuration looks correct at first glance. A quick scan of the user manual (https://bzbgear.com/wp-content/uploads/2020/manuals/BG-B20SA-manual.pdf) however seems to suggest two things:
> - This specific camera model uses port 3001 (see chapter 4.2.6)
> ...


Time was limited today, but I tried all of that with no luck. Is there a way to delete the uncooperative camera from the script setup while leaving the one that's working, or would I have to remove the script altogether and start over?
Is there anything I should check in the camera configuration? It says the visca port is 1259, but is that for visca over serial? The PTZ camera also says 1259 there, and it works fine with the script showing port 52381.


----------



## vwout (Jan 25, 2022)

You can reduce the camera count to 1 and reload the script, that will remove (or actually: hide) the settings for the B20SA.

Do you have a utility or script that comes with the camera to control it via Visca over IP?
Visca over Serial uses a serial connection, not a network connection and for that the port is not applicable, so unless the manual is wrong, the port is 3001. Port 1259 however is used by PTZOptics, so it could make sense to set it to port 1259 and mode PTZOptics.


----------



## RolandW (Jan 26, 2022)

Yes, that's what I was getting at: the Visca port setting on the camera itself (4.2.6 in the B20SA user manual) is irrelevant here because it applies only when you're using Visca over a serial connection, correct?
I'm pretty sure I did try 1259 in conjunction with PTZOptics mode, with no success. But I can double-check next time I'm there. I can take more screenshots or send logs if that would help. I did not see any obvious error messages.
I use the BZB web client (described in 4.2.1) for creating and activating zoom presets on the B20SA, and it works well. I assume the client is using Visca over IP? I have a browser dock in OBS for each camera. The client displays the same controls for pan, tilt, zoom and focus regardless of whether the camera supports all of those functions. I don't have to use it to activate presets for the PTZ camera because your script works so well with it.
One problem I've had with the PTZ is that it will sometimes lose focus when zoomed in fairly tight, and the autofocus has to hunt to find its place back. Because of that I usually set focus to manual for the sermon using the web GUI, but I've found that if a scene containing the Visca script is the _Program_ scene, the camera seems to remain in autofocus mode and thus can still wander. So once the camera has been positioned by the script, I switch to the plain PTZ camera scene (with no script source). If I then set the camera to manual focus, it stays put. Stated differently: it seems that changes to a camera's focus mode while that camera's script-controlled scene is in _Program_ do not have any effect on the camera's focus behavior.
Thank you!


----------



## vwout (Jan 26, 2022)

> the Visca port setting on the camera itself (4.2.6 in the B20SA user manual) is irrelevant here because it applies only when you're using Visca over a serial connection, correct?


No. Visca over serial uses RS232 or RS485, see chapter 5. There is no port in Visca over serial (only a camera address, but that is a totally different topic).



> I assume the client is using Visca over IP?


Probably not. Hard to tell without the physical camera, but a camera webUI typically uses a web API.



> One problem I've had with the PTZ is that it will sometimes lose focus ...


That is something in control of by the camera. The plugin does not control (auto)focus. When there is little contrast in view, your camera might have trouble focusing. It's not a DSLR with phase detection AF. Instead it probably applies image processing software.



> I've found that if a scene containing the Visca script ... the camera seems to remain in autofocus mode ...


The only thing this plugin does is recall a preset. If the focus mode is part of the preset, it is recalled to what you saved in the preset.



> it seems that changes to a camera's focus mode while that camera's script-controlled scene is in _Program_ do not have any effect on the camera's focus behavior.


What happens depends on what you configured. The script recalls a preset. When the focus mode is included in the preset (whether or not, is determined by the camera firmware), it is recalled with the preset. When the behavior is different between Preview and Program, you probably change the 'Action Active' configuration in de scene settings to 'On Program' or 'On Preview' instead of 'Always'.


----------



## RolandW (Jan 30, 2022)

Here is a screenshot of the _Network Port_ configuration for the camera that doesn't work (the settings are identical for the one that does work). Both cameras have 1259 here for _Port Visca_. In the script setup, both are set up for port 52381.


----------



## RolandW (Jan 30, 2022)

vwout said:


> The plugin does not control (auto)focus...


Yes, I am aware of all that, thank you. I have a workaround so I probably shouldn't have mentioned it. I have tried saving the preset with the camera manually focused but it does not save that focus distance with the preset. When I call that preset – either with the script or by picking it in the BZB UI – the camera still "hunts" for the focus, which indicates to me that it is in autofocus mode, not manual. Bottom line is that I don't think this "save the focus mode with the preset" feature works on this camera.


----------



## vwout (Jan 31, 2022)

RolandW said:


> Here is a screenshot of the _Network Port_ configuration for the camera that doesn't work (the settings are identical for the one that does work). Both cameras have 1259 here for _Port Visca_. In the script setup, both are set up for port 52381.


Based on this, I'd suggest to configure the port in the plugin to 1259 and set the mode to PTZOptics.


----------



## RolandW (Jan 31, 2022)

Will do, but I'm pretty sure I've already tried that – and every other combination of ports (1259, 3001, 52381) and modes I can think of. Thanks!


----------



## RolandW (Feb 1, 2022)

To quote another user: Got it working! So cool!!!
I was trying various combinations of port and mode, and clicked the _Reload Script_ button. All of a sudden it started working. The port is now 52381 and mode is PTZOptics. I am positive I had tried that combination before without success. Did I simply need to click _Reload Script_ after making the change?


----------



## vwout (Feb 2, 2022)

Great that you got it to work!

I should have thought about the script reload. Yes, when you (attempt to) use the plugin in a scene, a connection is created. Its configuration will only be forcefully be updated after a script release.


----------



## RolandW (Feb 5, 2022)

Thank you again for providing this and continuing to improve it!


----------



## JVRaines (Mar 1, 2022)

This script looks promising for my use, especially the animation function. Would it be possible to add a configurable delay before the preset is called? I am using a stinger that takes 1 second to wipe on the screen and the cam needs to be still for that period. Currently, I handle it with a browser source calling Javascript with setTimeout and fetch. It's a little arcane and VISCA would be cleaner.


----------



## vwout (Mar 2, 2022)

Sure, that doesn't look hard to add. I will include it in the next release.
As a small bonus, it might even allow adding multiple Visca commands in the same scene, to be executed sequentially based on configured delays...


----------



## vwout (Mar 6, 2022)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 1.6



> This release adds several features and contains a significant number of reworks to improve the code quality.
> 
> New features:
> 
> ...



Read the rest of this update entry...


----------



## vwout (Sep 15, 2022)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 2.0



> A second major release of the Visca over IP control plugin for OBS!
> 
> This release contains many and significant changes to the code to enable several new features, completely backward compatible with all previous releases.
> 
> Most noticeable is the integration of a nice new feature suggested and initially implemented by user tmimlitch. The current pan, tilt and zoom value of a camera can be retrieved and stored in a scene action, which are recalled when the scene becomes active. This means...



Read the rest of this update entry...


----------



## vwout (Sep 15, 2022)

One additional note: the plugin tries to detect the camera brand, model and version. This will be shown with the camera in the scripts settings under 'Version Info'. This information is provided by the camera as codes. If your camera provides this information and the plugin shows this as '_Vendor: Unknown (vvvv), Model: Unknown (mmmm), .._.', please share the actual *vendor *and *model *name and the *vvvv *and *mmmm *shown in the plugin, so this information can be added.


----------



## ghostman90215 (Sep 18, 2022)

This version is amazing! Great job!


----------



## Jeggins (Oct 15, 2022)

Hi and thanks for this script so far :)

I managed to add position recalls to ma scenes but I have the problem that i can recall a saved position exactly 3 times. After that the cam is not responding. I have to reload the script to have 3 more position recalls :D

I have the "NewTek NDI PTZ1" camera.
I tried the PTZOptics Mode but with that i had no camera movement at all. I added two logs from the OBS scriptlog. The first one shows 4 scene changes with 3 successfull cam preset recalls and the last one failing. The second log shows some unfinished messages that i get when i reload my script.


----------



## vwout (Oct 16, 2022)

Hi Jeggins,

You are welcome :)

To start with log2, this is because not all replies from the camera can be linked to a send message.
From the logs, it looks like the camera has some issues:
- not sending its own Vendor data (it identifies as Sony)
- it seems to be sending incorrect message counters on reply's
Both should not prevent the plugin from sending more commands to the camera, but this looks suspicious.

One question for confirmation: you are only sending the preset recall command after the previous command has been fully completed, so when the camera has reached the preset position? It looks like that looking at the logs, but just to be sure.
The test you are doing is recalling respectively preset 2, 3, 4 and 1. The call to preset 1 is failing. Although you probably tested this, could you try sending preset 2, 3, or 4 again - so sending a 'known good' preset recall?

When this continues to fail, could you modify `libvisca.lua` at line 941 and change:
`message.seq_nr = self.last_seq_nr`
to
`message.seq_nr = 0`

On a side note: your camera seems to still have stock firmware (revision 104). The latest at the NewTek site is 121 (VHR121F, see https://www.newtek.com/downloads/). Besides testing the above, you could also try a firmware update.


----------



## Jeggins (Oct 22, 2022)

Hi vwout,
thanks for your quick reply.
changing the mentioned line in the libvisca.lua did the job :) thank you very much!!

doublechecked my firmware version but I am at version VHR121F as you can see here:




Thank you again for the script ;) loving it


----------



## vwout (Oct 22, 2022)

Hi Jeggins, thanks for the confirmation. That means the Visca-over-IP implementation of this camera has several bugs. I will implement compatibility in the plugin, so you don't have to manually modify the script in case you update in the future. You can track the fix here: https://github.com/vwout/obs-visca-control/issues/7


----------



## vwout (Jan 5, 2023)

vwout updated Control Visca-over-IP based cameras with a new update entry:

Release 2.1



> A small update release introducing a few additional capabilities
> 
> - Add functions for changing color gain (saturation) and brightness (#8). The color gain can be increased on the fly using assignable shortcut keys, or can be set to a fixed value as scene action.
> - Add API commands to libvisca for reset/set/get Color Gain (Saturation) and set/get Brightness.
> ...



Read the rest of this update entry...


----------

