Skip to main content
On this page

CCTV cameras & recorders

Open the CCTV console from a camera or recorder’s target inspector to view channels, control PTZ, search and export recordings, check disks, or manage on-device accounts. Available operations depend on the device family and your permissions.

How the CCTV plane differs from a remote session

The CCTV console runs client-side over individually authorized REST calls: it creates no session record, WebSocket, or session token, and does not appear in Active sessions. Reopening a camera focuses its open tab, and closing drops the tab locally. Direct route: /connections/cctv/<target id>.

Supported device families

Four families are supported. The family is a typed value, never a guess from a brand string.

FamilyWire idProtocolDefault portTypical hardware
DVRIP / Sofiadvrip_sofiaSofia (XMeye / NetSurveillance) JSON over raw TCP34567The Xiongmai OEM tree — Polyvision, Hunter, Optimus, Tantos, Jasun
DahuadahuaHTTP CGI with Digest auth80Dahua, Amcrest, Lorex, EmpireTech
HikvisionhikvisionISAPI over HTTP with Digest auth80Hikvision, HiLook
ONVIFonvifONVIF SOAP over HTTP with WS-Security UsernameToken80Any camera exposing a conformant ONVIF profile

What each family can do

Every driver publishes a manifest of twelve capabilities. The console renders a control only when the capability and your permission both allow it, so this table predicts what an operator will actually see.

CapabilityDVRIP / SofiaDahuaHikvisionONVIF
Device infoyesyesyesyes
Channel listyesyesyesyes
Snapshotyesyesyesyes
Live streamingyesyesyesyes
PTZyesyesyesyes
Recording statusyesyesyesno
Recording searchyesyesyesno
Clip exportyesyesyesno
Disk statusyesyesyesno
On-device usersyesyesyesno
Edit an existing useryesyesyesno
Authority catalogueyesnonono

DVRIP/Sofia is the only family with all twelve, and the only one that can enumerate the device's own permission-token catalogue. Dahua and Hikvision carry eleven. ONVIF is view-only by construction: user listing, user creation, user deletion, disk status and recording status each return an explicit unsupported answer, so an ONVIF camera shows no Archive tab and no Users tab. Optional driver methods return unsupported when the device family does not implement them.

Setting up a device

Prerequisite: the platform driver

A connection target becomes a CCTV device because its inventory Platform carries a network-automation (NAPALM) driver slug that parses to a known family. Set it under Inventory → Resources → Platforms to dvrip_sofia, dahua, hikvision or onvif. There is no CCTV section in platform settings — this field is the switch. See Inventory.

The CCTV connection profile

Access parameters come from a connection configuration record (or a config-context entry) with protocol cctv. The profile carries five fields:

FieldMeaning
hostManagement address; omit to use the target's own inventory address
mgmt_port1–65535; omit to use the family default port
channel0–65535; stored on the profile
familydvrip_sofia, dahua, hikvision or onvif
credentialsusername (required, non-empty) and password

Unlike SSH, RDP and VNC there is no timeout field. Config-context entries under piping.connections.cctv[] are validated strictly against exactly this shape — any other key, or a port outside its range, is rejected at write time.

Resolution precedence is: params.host, else the target's own address from the connections read model (a reserved placeholder such as {{primary_ip4}} means "use the target's own address"); params.family, else the platform's driver slug; params.mgmt_port, else the family default. Inheritance is the normal scope-and-template merge — most specific first, first account wins.

Credentials and the secret fence

credentials.password is either a literal value or a bare secret-vault UUID.

Through the typed cctv connection profile a literal password is used verbatim, exactly as the connect path treats an SSH/RDP/VNC password — the plain password field works without a separate vaulting step. A password written into a config context must be a vault UUID; a literal there fails validation when the context is saved.

A UUID is dereferenced only when it is properly bound: to the target under consumer connection_scope:connection_target, or to the record that produced this leaf under connection_config:record at field key credentials.password. An unbound UUID is never read — the resolver falls back rather than trusting it, and a bound-but-empty secret falls back too. credentials.password is a secret field, so it is stored and redacted as one. See Credentials and Secrets.

The CCTV console

The console is a four-tab strip. A tab appears only when both your per-target permission and the driver capability allow it, so a missing grant hides a section rather than failing it.

TabRequires
Camerasview permission and streaming, snapshot or channel capability
Archiverecordings permission and the recording capability
Usersusers permission and the on-device users capability
Deviceview permission with device info, or settings permission with disk status

The Device tab shows device identity (model, firmware, serial, channel count, device time) and disk health — each storage device with a used/total bar and a state chip of OK, read-only, error or unknown.

Failures appear inside the affected card; other sections remain usable. Unsupported operations have no retry action.

Live view and channels

The Cameras tab is a single live-view card with a source toggle:

  • Stream restreams the channel as MJPEG, transcoded server-side from the device's RTSP feed. Frame rate is clamped to 1–15 (default 6) and width to 320–1920 px (default 1280, never upscaled). Closing the response tears the transcode down.
  • Stills repeatedly fetches a single JPEG frame, on demand or every three seconds. It is the low-bandwidth option and the only one offered when a family cannot stream.

Channel naming degrades in three steps: the device's own named channel list where the family can enumerate it, else a bare 1..N synthesized from the reported channel count, else a single default view with no selector.

With more than one channel a Single/Grid toggle appears; the 2×2 / 3×3 / 4×4 size select appears only while grid mode is on. Channel chips are shown in single mode only — in grid mode each cell carries its own picker, and clicking a cell promotes that channel to single view. Grid cells deliberately run a reduced shape (3 fps, 640 px, five-second stills) to stay inside the media budget. View settings are remembered per target in the browser, and streams pause when the tab is backgrounded.

Moving a camera (PTZ)

PTZ is a press-and-hold pad: a directional cross plus zoom in/out. Pointer-down starts a continuous move and releasing, leaving or losing focus stops it; Enter and Space behave the same way for keyboard users. Each gesture is a move command followed by a stop command.

PTZ passes two independent gates:

  1. Family capability — a hard refusal before any device I/O. All four families advertise device-level PTZ.
  2. Per-channel discovery — only a channel the device positively reports as unsupported is refused. An unknown verdict, a channel absent from the list, or a failed probe all fall through to the device's own answer.

The console is stricter than the API: the pad is hidden — never disabled, never allowed to error — unless the driver reports PTZ, you hold the ptz permission, and the selected channel reports supported. It is also hidden in grid mode, since no single camera is selected there. Preset recall exists in the device protocol but has no console control today.

The recording archive

The Archive tab is one Recording card: the device-wide footage window and the Export button, then the per-channel player with its timeline, then the device-wide status chip, recorded-span count and span list. The tab itself needs the recordings permission and the recording capability; the player, its timeline and the Watch button additionally require the driver's export capability, so a family that reports recording without export shows the summary and no player.

Search, playback and export

Three distinct operations:

  • Search (/recordings) lists footage on a channel between two timestamps. It transfers no media and opens no device session. Use it to find the window before starting playback.
  • Playback (/playback) streams the window as MP4 for viewing in the browser.
  • Export (/export) streams the identical MP4 bytes as a download.

Playback and export stream fragmented, chunked video/mp4 without buffering the full clip. They differ in content disposition and permission (recordings vs export). Downloaded clips are named clip-ch<N>-<ISO timestamp with ":" and "." removed>.mp4.

Where the family exposes a native file download, export and playback take a fast path — the device file is pulled directly from the device and repackaged without re-encoding, several times faster than realtime. Otherwise the family's RTSP playback window is copied at realtime and cut precisely. Hikvision takes the fast path only when the found segment falls entirely inside the requested window, because the device serves whole segment files: a partially overlapping segment would deliver the entire file, so a one-minute request could otherwise cost a gigabyte. If the remux capacity is exhausted the request falls through to the realtime path rather than being refused.

Window limits

OperationCapOverride
Recording search30 daysnone — a hard constant
Playback and export2 hoursPIPING_CCTV__MAX_EXPORT_WINDOW_SECS (default 7200)

Search transfers no media and opens no device session. For all windows, the end must be after the start. Timestamps use RFC 3339; the start is inclusive and the end exclusive.

Raising PIPING_CCTV__MAX_EXPORT_WINDOW_SECS applies to direct API calls; the web client enforces a 2-hour window.

When the recording will not play

These recorders commonly write H.265, which most browsers refuse to decode, so a faithful copy can be unwatchable. Adding transcode=true to a playback request re-encodes to H.264 baseline. It costs real CPU, so it is never implicit — the player asks for it only after the browser has actually failed, and offers an export if the retry also fails. Export always keeps the device's own encoding.

On-device user accounts

The Users tab lists the recorder's own accounts with their group and authority tokens, and can create, edit and remove them.

Creating and deleting are a two-step flow: a dry-run preview classifies every requested name as create, skip, delete or missing with a reason, and only an explicit confirmation applies it. Editing an existing account is a direct write with no dry run. The account name is the identity and is never changed; only the facets you supply are edited, and an update that changes nothing is rejected. Each write reports per-account outcomes, so a device rejecting one account is visible inside the result rather than failing the whole call. Passwords are write-only and are never echoed back.

Authority tokens come from the device's own catalogue where the family exposes one — DVRIP/Sofia only. On the other three families the console falls back to the tokens already present on existing accounts, plus a free-text field for an exact device token.

The same operations run across many targets at once through fleet endpoints — POST /api/v1/device-fleet/users:preview, :create and :delete. These are an API-only capability with no screen today. Targets you lack the users permission on are marked not_permitted and excluded, and the permitted subset proceeds, rather than the whole call failing.

Permissions

CCTV is its own RBAC resource type, cctv, with six purpose-built actions instead of the generic CRUD verbs. Each is granted per target, and broad connection-target read access never implies CCTV access.

OperationRequired action
/channels, /info, /snapshot, /streamview
/recording, /recordings, /playbackrecordings
/exportexport
/users (read and write), /users:preview, /users:create, /users:delete, /authoritiesusers
/disksettings
/ptzptz
/capabilitiesany one of the six

Disk health requires settings permission, the authority catalogue requires users, and playback requires recordings.

In a policy the actions appear as CCTV_VIEW … CCTV_PTZ. In a personal-access-token scope they reverse the platform's usual order: CCTV scopes read cctv:view, cctv:recordings, cctv:export, cctv:users, cctv:settings, cctv:ptz — resource first — where every other resource is written <action>:<resource>, for example read:inventory.

The quickest way to grant CCTV access is the ready-made cctv-operator role, seeded on first boot with all six actions over the CCTV resource type. The full-access administrator policy covers CCTV automatically. Otherwise build an allow policy naming whichever subset you need. See Access control.

Scoping access by attribute

A CCTV policy may carry attribute constraints on seven keys: role_id, site_id, region_id, tenant_id, platform_id, cluster_id and status. region_id is an exact-id match — a policy scoped to a parent region does not cover sites in its child regions.

Do not use protocol constraints in CCTV policies: the CCTV enforcement path does not evaluate protocol.

Deployment prerequisite: direct network reach

CCTV traffic goes directly from the backend process, not through proxy nodes. The backend host must be able to reach every recorder you manage; a camera reachable only from a remote LAN behind a proxy node cannot be managed.

ffmpeg ships inside the API runtime image and all four media adapters are attached unconditionally, so live view, the snapshot fallback, clip export and remux work out of the box. PIPING_CCTV__FFMPEG_PATH exists only for images that ship the binary under a different name.

Security

An ONVIF camera answers a snapshot request with a device-chosen, credential-bearing absolute URL. Piping never hands that URL to a client — it fetches it server-side behind an SSRF fence: the scheme must be http or https, and the URL host must equal the device's own host, so a pivot to an internal metadata endpoint fails closed. The host is resolved once and the HTTP client pinned to those addresses, so a DNS rebind between the authentication probe and the retry cannot redirect either request. No HTTP redirects are followed at all, the body is capped at 8 MiB, and it must start with a JPEG marker so an HTML error page is never surfaced as an image.

Device passwords never leave the system. Snapshots and clips are returned as binary bodies, never as credential-bearing URIs, and secret values are wrapped in a type whose debug output is redacted. Every operation authorizes the action against resource cctv for that specific target, with the target's own inventory attributes fed into the policy evaluation.

Capacity and tuning

Live streams, still grabs, realtime clip copies, and native downloads each have a concurrency limit and share a process-wide memory budget. An operation must fit both limits or it is refused with 429. Budget reservations do not wait for capacity.

All keys below are environment variables prefixed PIPING_CCTV__. See Configuration reference.

KeyDefaultBounds
LIVE_MAX_STREAMS8Concurrent live streams. Memory-bound: each transcode holds roughly 300 MB
LIVE_FIRST_FRAME_TIMEOUT_SECS15Wait for the first frame
LIVE_STALL_TIMEOUT_SECS30Silence before a stream is considered stalled
LIVE_MAX_SESSION_SECS43200Backstop on one live session (12 h)
LIVE_PREFER_SUBSTREAMfalseTry the channel's lower-resolution substream first
STILL_MAX_GRABS8Concurrent snapshot grabs
STILL_TIMEOUT_SECS12Snapshot timeout
CLIP_MAX_EXPORTS3Concurrent realtime RTSP clip copies
CLIP_FIRST_CHUNK_TIMEOUT_SECS90Wait for the first clip bytes
DOWNLOAD_MAX_EXPORTS3Concurrent native download + remux operations
DOWNLOAD_FIRST_CHUNK_TIMEOUT_SECS90Wait for the first downloaded bytes
DOWNLOAD_IDLE_TIMEOUT_SECS90Idle gap before a download is abandoned
DOWNLOAD_MAX_DURATION_SECS3600Ceiling on one native download
MEDIA_BUDGET_TOTAL_MB2400Shared memory budget across all four planes
MEDIA_BUDGET_UNIT_MB10Budget unit; live costs 30 units, the other planes 1 each
MAX_EXPORT_WINDOW_SECS7200Playback and export window cap
FFMPEG_PATHffmpegPath to the ffmpeg binary

Automation

CCTV is reachable from the MCP server: thirteen curated CCTV operations covering capabilities, channels, PTZ, device info, disk, recording state, recording search and the full on-device user set, plus three dedicated media tools — snapshot, playback and export.

Each media tool surfaces in the tool list only when the token carries the matching scope: snapshot needs cctv:view, playback cctv:recordings, export cctv:export. Playback and export are separate tools with distinct permission requirements (cctv:recordings vs cctv:export). Every call checks both the token scope and per-target policy rules. A snapshot is returned as a short-lived resource link capped at 8 MiB; media paths are excluded from the generic REST tool. Fleet user operations are also exposed.

REST API reference

Every CCTV operation lives under one prefix and is keyed by connection-target id — the same id SSH, RDP and VNC use:

/api/v1/cctv/{target_id}/...
MethodPathPurposeAction
GET/capabilitiesDriver capabilities plus your six verdictsany
GET/channelsChannels with names, enabled flag and PTZ supportview
GET/infoModel, firmware, serial, channel count, device timeview
GET/snapshotOne JPEG frame (channel)view
GET/streamLive MJPEG restream (channel, fps, max_width)view
POST/ptzMove, stop or recall a presetptz
GET/diskStorage devices with used/total and statesettings
GET/recordingDevice-wide recording state and spansrecordings
GET/recordingsPer-channel span search (channel, start, end)recordings
GET/playbackMP4 for inline viewing (transcode)recordings
GET/exportThe same MP4 as a downloadexport
GET/usersOn-device accountsusers
PUT/usersEdit accounts (direct write, no dry run)users
POST/users:previewDry-run classification of a create or deleteusers
POST/users:createCreate accountsusers
POST/users:deleteRemove accountsusers
GET/authoritiesDevice permission-token catalogue (DVRIP/Sofia only)users

The full contract lives in the API reference.

Troubleshooting

Device failures are mapped to protocol-neutral codes with a fixed generic message. The device's own text is never returned to the caller.

StatusCause
400Authentication rejected, credentials missing, or the family does not implement the operation
403Your policy does not grant that CCTV action on this target
429The plane's concurrency limit or the shared media budget is exhausted
502The device is unreachable, or the exchange failed
504The device did not answer in time

Common questions:

  • A tab is missing. Both the permission and the driver capability must allow it. An ONVIF camera has no Archive and no Users tab by construction.
  • The Archive tab has no player. The family reports recording state but not clip export.
  • The PTZ pad is missing. It requires the driver capability, your ptz permission, and a selected channel the device positively reports as PTZ-capable. It is also hidden in grid mode.
  • A section says the operation is unsupported. The family does not implement it; retrying will not help.
  • The console has no tabs at all. The capabilities read failed — either a resolution problem (no family, no address, or no usable credentials), or a caller holding none of the six CCTV actions, since /capabilities requires at least one.

See also Troubleshooting and Connections.