Ptz visca

From damionrashford/media-os · View interactive version

Ptz visca is an AI agent skill from the GitHub repository damionrashford/media-os. Control PTZ cameras with Sony VISCA protocol (RS-232/485 serial 9600/38400 8N1, or UDP:52381 with 8-byte payload header): pan/tilt/zoom/focus/exposure/WB commands, libvisca + libvisca-ip, python-visca, pyvisca, pysca, visca-over-ip. Supported cameras: Sony (BRC/SRG/FR7/FCB modules), PTZOptics, AVer

How to use this skill

Skill file

PTZ VISCA

Context: $ARGUMENTS

Send Sony VISCA commands to a PTZ camera over serial (RS-232C/422/485) or IP (UDP:52381). For spec lookup / command byte tables see ptz-docs. For IP cameras without VISCA (ONVIF Profile S/T) use ptz-onvif.

Quick start

When to use

Step 1 — Pick the transport

Pass --transport serial|udp-ip to viscactl.py. Default is udp-ip.

Step 2 — Identify the camera

Address 1–7 (broadcast 8). First byte = 0x80 | addr on wire.

| Camera | Default port | Default addr |

|---|---|---|

| Sony BRC-H900 | 52381 | 1 |

| Sony SRG-300H | 52381 | 1 |

| Sony FR7 | 52381 | 1 |

| PTZOptics (G2/G3/Move SE/Move 4K) | 1259 (legacy) / 52381 (modern) | 1 |

| AVer Pro-AV (PTZ310 etc.) | 52381 | 1 |

| Panasonic AW-UE | 52381 | 1 |

PTZOptics legacy firmware uses port 1259; newer units standardized on 52381. Check the camera's OSD/web UI if in doubt. Use --port to override.

Step 3 — Drive the camera

# IP (default)
uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py pan-tilt \
    --host 192.168.1.100 --address 1 \
    --x 8 --y 0 --duration 1.5

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py zoom \
    --host 192.168.1.100 --direction tele --speed 4 --duration 1

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py preset \
    --host 192.168.1.100 --action recall --number 2

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py focus \
    --host 192.168.1.100 --mode auto

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py power \
    --host 192.168.1.100 --action on

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py home --host 192.168.1.100
uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py reset --host 192.168.1.100

# Serial
uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py pan-tilt \
    --transport serial --serial-port /dev/tty.usbserial-AB0J8W5C --baud 9600 \
    --x 0 --y 6 --duration 1

# Raw escape hatch
uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py raw \
    --host 192.168.1.100 --hex '81 01 04 3F 02 01 FF'

Every command supports --dry-run (print packet, skip send) and --verbose (trace bytes on stderr).

Step 4 — Read the reply

After a Command, expect ACK (y0 4z FF) then Completion (y0 5z FF). After an Inquiry, expect Completion carrying the data. Errors return y0 6z ee FF where ee is:

| ee | Meaning |

|---|---|

| 01 | Message length error |

| 02 | Syntax error |

| 03 | Command buffer full |

| 04 | Command canceled |

| 05 | No socket (to cancel) |

| 41 | Command not executable |

For IP transport, the 8-byte payload header on replies uses payload type 0x0111 (VISCA reply).

Gotchas

Examples

Example 1 — Nudge left 1 second

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py pan-tilt \
    --host 192.168.1.100 --x -6 --y 0 --duration 1

Example 2 — Save preset 3 at current position

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py preset \
    --host 192.168.1.100 --action save --number 3

Example 3 — Manual focus, push near

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py focus \
    --host 192.168.1.100 --mode manual
uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py focus \
    --host 192.168.1.100 --mode near --speed 3 --duration 1

Example 4 — Broadcast "Home" to every camera on the bus

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py home \
    --host 192.168.1.100 --address 8

Example 5 — Dry-run the bytes before sending

uv run ${CLAUDE_SKILL_DIR}/scripts/viscactl.py zoom \
    --host 192.168.1.100 --direction tele --speed 4 --duration 1 --dry-run

Reference docs

Python library alternatives

Troubleshooting

Timeout, no reply

Cause: Wrong port (1259 vs 52381), wrong address, or camera VISCA disabled in OSD.

Solution: Ping the camera, check VISCA-over-IP enabled in camera web UI, try --port 1259 for older PTZOptics.

Reply carries `ee=02` Syntax error

Cause: Invalid byte sequence — wrong speed range, wrong nibble packing.

Solution: Check references/commands.md for the exact shape. Use --dry-run --verbose to inspect bytes before sending.

Reply carries `ee=03` Command buffer full

Cause: Sent commands faster than the camera could complete them.

Solution: Wait for Completion before sending the next, or throttle to ~10 Hz.

Reply carries `ee=41` Command not executable

Cause: Valid syntax but the camera can't run it now (e.g. focus direct when in AF, preset >127 on strict Sony).

Solution: Change state first (e.g. focus --mode manual) then retry.

pyserial not installed

Cause: --transport serial without the optional pyserial dep.

Solution: pip install pyserial — or switch to --transport udp-ip.

Packets arrive but camera doesn't move

Cause: Pan/tilt speed = 0 (stop), or direction bytes wrong (03 03 = stop).

Solution: Use non-zero --x/--y magnitude; see the direction matrix in references/commands.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.