PTZ camera control over UDP

1,013 views
Skip to first unread message

Alex Danson

unread,
Feb 22, 2022, 11:43:26 AM2/22/22
to QLab
hi,

Anybody using PTZ camera control over UDP in Network Cue? I have the right setup, right port, and right string to send, still I probably have the wrong syntax, because it doesn't work...
Here is what the documentation tells me to send:
CAM_Memory Recall: 81 01 04 3F 02 pp FF  (where pp is preset number)
I tried that, i tried only the numbers, no luck

Any suggestions?

thanks
Alex

Sam Kusnetz

unread,
Feb 22, 2022, 5:44:05 PM2/22/22
to ql...@googlegroups.com
Hi Alex

Network cues cannot send hex strings, only ASCII text, and that’s the reason this isn’t working for you.

For now, you’ll need to use a Script cue with “do shell script” and netcat to send hex.

Best
Sam

Sam Kusnetz (he/him) | Figure 53



--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/9c90f33c-af76-487c-8797-558cc912b286n%40googlegroups.com.

Alex Danson

unread,
Feb 22, 2022, 7:57:28 PM2/22/22
to QLab
hi Sam, so I can't just convert to decimal numbers, camera wants hex?

Anyway I was able to move it with the correspondent TCP command in a script, thanks to Charles(!)..., but just for kicks, what would be the syntax to put in a script? The camera's IP address is 10.0.0.20 and the command should be CAM_Memory Recall: 81 01 04 3F 02 pp FF where pp is the preset number, for example 02

thanks

Sam Kusnetz

unread,
Feb 22, 2022, 8:25:20 PM2/22/22
to ql...@googlegroups.com
Hi Alex

Is “CAM_Memory Recall:” part of the command?

If so, I’m afraid I don’t know much about how to combine text and hex in one command but my guess is:

do shell script "echo -ne \CAM_Memory Recall: \x81\x01\x04\x3f\x02\x02\xff\" | nc 10.0.0.20 PORT

You’ll need to replace PORT with the port number that your camera is listening on.

Best
Sam

Sam Kusnetz (he/him) | Figure 53

Alex Danson

unread,
Feb 23, 2022, 10:05:53 AM2/23/22
to QLab
compilation fails, at the first "x", even if i take out "Cam_memory recall" part...

do shell script "echo -ne \"\x81\x01\x04\x3f\x02\x02\xff\" | nc 10.0.0.20 1259

and shouldn't be a closing " somewhere?

Alex

Sam Kusnetz

unread,
Feb 23, 2022, 10:29:53 AM2/23/22
to ql...@googlegroups.com
Hi Alex

Ah, yes! I missed a closing quote at the very end.

Also as I said, it might not work at all! I have very little experience sending hex via netcat.

Best
Sam
Sam Kusnetz (he/him) | Figure 53

Alex Danson

unread,
Feb 23, 2022, 10:36:17 AM2/23/22
to QLab
yeah, no, the script doesn't like that "x" for some reason, my scripting skills are at the copy/paste level... anyway, thanks to Charles, I am able to do what I needed,

thank you
Alex

Screen Shot 2022-02-23 at 7.32.11 AM.png

micpool

unread,
Feb 23, 2022, 10:36:29 AM2/23/22
to QLab

I think Sam’s netcat command is correct apart from a closing  quote at the end of the hex

Here’s a reference on stack exchange, obviously you need the do shell script 


Mic

Alex Danson

unread,
Feb 23, 2022, 10:38:42 AM2/23/22
to QLab
look at my screenshot above, it doesn't like something

micpool

unread,
Feb 23, 2022, 10:51:12 AM2/23/22
to QLab
Ah, do the backslashes need escaping to?

do shell script "echo -ne \"CAM_Memory Recall: \\x81\\x01\\x04\\x3f\\x02\\x02\\xff\" | nc 10.0.0.20 PORT"

Mic

Alex Danson

unread,
Feb 23, 2022, 11:27:28 AM2/23/22
to QLab
now it compiles successfully, but the camera doesn't move. I tried to take out ":", then "recall" then "cam_memory". No well, the TCP command works, or as they say in show-biz, "we'll always have Paris".
In case someone else wants to do the same thing, here it is:
do shell script "curl" & " \"http://CAMERA.IP.ADDRESS.HERE/cgi-bin/ptzctrl.cgi?ptzcmd&poscall&x\"" where "x" is the desired preset to be called

Thanks
Alex

micpool

unread,
Feb 23, 2022, 12:03:23 PM2/23/22
to QLab
On Wednesday, February 23, 2022 at 4:27:28 PM UTC alexd...@gmail.com wrote:
now it compiles successfully, but the camera doesn't move. I tried to take out ":", then "recall" then "cam_memory". No well, the TCP command works, or as they say in show-biz, "we'll always have Paris". 

Thats a shame. I don't have a camera to hand to refine the shell script but it must be very close.  The Cam_memory recall stuff is definitely not part of the command. Visca over IP commands are just the Hex


Mic

micpool

unread,
Feb 23, 2022, 12:06:12 PM2/23/22
to QLab
Does it need a -u after -nc to specify UDP
Mic

Alex Danson

unread,
Feb 23, 2022, 12:35:36 PM2/23/22
to QLab
this is what I got now, no errors either in compiling or in executing the cue, but camera still doesn't move
do shell script "echo -ne \"\\x81\\x01\\x04\\x3f\\x02\\x02\\xff\" | nc -u 10.0.0.20 1259"

P.S. love your perseverance... I am the same way, unfortunately :-)

micpool

unread,
Feb 23, 2022, 1:03:56 PM2/23/22
to QLab
Actually we were nowhere near. It was sending the x as x before every Hex Byte as text 

This is my last, final final,  final  attempt, and I can see in Wireshark that it is  sending the correct  consecutive Hex Bytes 

tell application id "com.figure53.QLab.4" to tell front workspace
        set thestring to "$\"\\x81\\x01\\x04\\x3f\\x02\\x02\\xff\""
        do shell script "echo -n -e  " & thestring & " | nc  -w 0  -u   10.0.0.20 1259"
end tell

Alex Danson

unread,
Feb 23, 2022, 1:12:59 PM2/23/22
to QLab
haha... final-final-final?... unfortunately, nope, no camera movement. It compiles and executes without errors

micpool

unread,
Feb 24, 2022, 10:58:47 AM2/24/22
to QLab
Absolutely the last one!
This definitely  sends the correct Hex and nothing but the correct Hex (probably!)

tell application id "com.figure53.QLab.4" to tell front workspace
        set thestring to "$\"\\x81\\x01\\x04\\x3f\\x02\\x02\\xff\""
        do shell script "echo   " & thestring & " | nc  -w 0  -u   192.168.1.53 1259" --change to your cameras IP 1259 is Fixed PTZ port
end tell

If its not working check that your camera is set to use  VISCA over IP

If that doesn't work check that you can send to the camera from Packet Sender using the instructions in this article.

https://help.ptzoptics.com/support/solutions/articles/13000077734-an-introduction-to-ip-control-scripting-for-ptzoptics-cameras

Alex Danson

unread,
Feb 24, 2022, 1:30:25 PM2/24/22
to QLab
unfortunately, still not moving... and yes, it is set to use Visca, it's a PTZOptics camera

micpool

unread,
May 20, 2022, 4:24:53 AM5/20/22
to QLab
Did you  ever get this working?

Alex Danson

unread,
May 20, 2022, 2:40:26 PM5/20/22
to QLab
yes, didn't I say? sorry... it works with a script:

thanks for your follow up. Hope it helps others
Alex

Andrew Lee

unread,
May 20, 2022, 2:56:25 PM5/20/22
to QLab
Hi Alex, 

Did you say you can control your PTZ camera with Qlab? are you able to fire PTZ save preset spots with Qlab? That would be so awesome to do..

micpool

unread,
May 20, 2022, 2:58:25 PM5/20/22
to QLab
Very good. Someone asked me about this today, and after looking at the 2 threads where we had tried to do this with VISCA over IP and found it quite difficult, I thought that a shell script using curl would be the  best option.  Here’s a link to the full protocol

Alex Danson

unread,
May 20, 2022, 3:20:02 PM5/20/22
to QLab
@als... yes I did :-)
Message has been deleted

Andrew Lee

unread,
May 27, 2022, 6:34:30 AM5/27/22
to QLab
Hi Alex, 

Would you be so kind to walk me through how to set this up with my PTZ camera?

Would greatly appreciate this!

Andrew Kanturek

unread,
May 27, 2022, 11:07:40 AM5/27/22
to ql...@googlegroups.com

How about trying…

 

        set thestring to "$\"\\\\x81\\\\x01\\\\x04\\\\x3f\\\\x02\\\\x02\\\\xff\""

        do shell script "echo -e " & thestring & " | nc  -w 0  -u   192.168.1.53 1259" --change to your cameras IP

 

Notice the “echo -e “ where:

The -e enables the interpretation of backslash escapes -> allowing to send hex codes.

--

Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.

Egill Ingibergsson

unread,
Jun 1, 2023, 8:39:33 AM6/1/23
to QLab
Has this changed with Qlab 5?
Is sending Visca over ip straight from Qlab possible with the HEX in Network?
I simply want to call on presets in Birddog cameras. For some reason some of them work through Bitfocus Companion but not all. Would be really nice to be able to contact the cameras straight from Qlab.
I tried without success, my knowledge in this area is limited.

Sam Kusnetz

unread,
Jun 1, 2023, 11:00:26 AM6/1/23
to ql...@googlegroups.com
Hello!

I don’t have full answers because it seems to me that Visca is just about the worst documented protocol in the world.

In any case, though, the Network cue in QLab 5 can send hex messages so you should be able to look up the commands you want to send and use a Network cue to send them.

Please do let us know if you have success!

Best
Sam
Sam Kusnetz (he/him) | Figure 53



Tauno Makke

unread,
Jun 1, 2023, 11:56:40 AM6/1/23
to ql...@googlegroups.com
Hi,

I personally have experience with BirdDog P240 cameras for a show we produced recently. After some research, and with the help of ChatGPT for formating the code correclty, we managed to get it working using script cues:

set curlCommand to "curl -X POST -H \"Content-Type: application/json\" -d '{\"Preset\":\"Preset-88\"}' http://192.168.100.100:8080/recall"

do shell script curlCommand

Just change the IP address accordingly.
There are other funtions available aswell, such as exposure etc.
For more hints, BirdDog RESTful API 2.0 https://birddog.tv/AV/API/index.html though most of the info about what the camera actually receives I gained through using their Keyboard controller Web UI API settings and builtin presets what you can SET or GET.

Also, sometimes the preset wont recall on first try, but then again, I am using RUDP.

Hope this helps.

Tauno



Egill Ingibergsson

unread,
Jun 2, 2023, 6:03:42 PM6/2/23
to QLab
Thank you Tauno, this might solve things. I will be looking into this further and report if successful with HEX.

Best,
Egill

Egill Ingibergsson

unread,
Jun 6, 2023, 6:37:44 AM6/6/23
to QLab
Thank you for your replies. I'll keep on looking into this and report if successful. Would rather do it with Visca but great to have the script also.
Yes the documentation of Visca is poor, here is a command list:
This video is also helpful, although it is specific to certain products:

Best,
Egill

fimmtudagur, 1. júní 2023 kl. 15:56:40 UTC skrifaði tauno...@gmail.com:

Egill Ingibergsson

unread,
Jun 9, 2023, 8:20:20 AM6/9/23
to QLab
It's working. See photo.
The last hex number before FF is the preset number. I had to set the hex numbers to -1, so 00 is preset 1 and 05 is preset 6. Then it seems to work properly. The same happens when I send the hex string from the very nice app packetsender.
Also  in the AVer paper to the right, it says you need to send a stop command after a movement. It seems to work fine without it and I'm not sure either when to send it. Should it be at the same time or after a while and how long then? No idea. When first I got it to work the camera actualy kept on moving slowly after a preset command but now it does not ... so maybe I'm not quite there.
Visca over ip.png

Paul

unread,
Jun 13, 2023, 9:54:58 AM6/13/23
to QLab
there is a lot of confusion here from reading this thread..
first when in Applescript you do shell script - which shell actually executes the command? The Borne shell (in /bin/sh) but the default shell (on MacOS) is the zsh. These two shells handle things differently!

from zsh this command will ring the bell, print A, a new line and ring the bell again

echo "\07\x41\xa\07"     # works in zsh

but it will not work as intended in bash (the default /bin/sh which Qlab  calls when you execute a "do shell script .." command from Applescript.

The way to make this non-shell dependent is to use printf with the bytes specifier %b

printf %b "\07\x41\xa\07"    # works in bash and zsh

You can always check what you are outputting, by piping the output of the command into xxd: open a Terminal window and enter (the \c on the end of the echo string stops the newline being printed)

echo "\07\x41\xa\07\c" | xxd

the output shows you the four bytes (in hex) and the character representation if printable (here only the A)

00000000: 0741 0a07                                .A..

From Applescript you also need to \quote the backslash character to ensure it gets passed to the shell, so from a script cue you need

do shell script "echo \"\\x41\""   # will return A

This Qlab script illustrates the above (also works with v4.7)

tell application id "com.figure53.QLab.5" to tell front workspace
-- this will display A
display dialog (do shell script "echo \"\\x41\"")
--display dialog (do shell script scr)
-- this will display A (newline) bc
set scr to "echo \"\\x41\\xa\\x62\\x63\\033\""
display dialog (do shell script scr)
-- this will display the actual bytes in hex
set scr to "echo \"\\x41\\x62\\x63\\c\" | xxd"
display dialog (do shell script scr)

-- this will send the bytes over the network via UDP to port 1234 on local machine
set scr to "echo \"\\x41\\x62\\x63\\c\" | nc -u  -w0  -n 127.0.0.1 1234"
do shell script scr
end tell

The options to nc (net cat) are -u to use UDP, -w0 is not to wait (otherwise the script may hang here), -n is don't do DNS lookups - if you are on a private network without DNS then this will save some problems.
Sometimes I find it easier to avoid all the \\quoting to put the script in a separate file (but that throws other complications into the mix if you are not familiar with permissions or editing files).


Maybe the Hex bytes option to the Network cue will help alleviate some of these problems! (OSC is just a particular format of bytes)
Then there is still the problem of poor documentation for the item you are trying to control. Bitstream Companion has the advantage here in lots of other people have done the hard slog.
Reply all
Reply to author
Forward
0 new messages