Skip to content

GB28181 National Standard Protocol

GB28181 is the Chinese national standard “Technical Requirements for Information Transmission, Exchange, and Control of Security Surveillance Video Monitoring Network Systems” (GB/T 28181), widely used for interoperability in video surveillance systems. Monibuca V6 provides full GB28181 signaling and media support.

PropertyValue
Signaling ProtocolSIP (UDP/TCP selectable)
Signaling Port5060 (default)
Media ProtocolRTP over UDP
Media Port10000-20000 (default range)
Publish✅ Supported (device pushes to platform)
Subscribe✅ Supported (platform requests stream from device)
Latency1-3 seconds
Feature Flaggb28181
  • Device registration and management: Supports device registration, heartbeat keep-alive, and catalog queries
  • Live video: Supports real-time video preview from devices
  • PTZ control: Supports pan, tilt, zoom, iris, and preset positions
  • Channel management: Supports multi-channel devices with independent management per channel
  • Platform cascading: Supports upper/lower platform interconnection
  • Recording query and playback: Supports device-side recording retrieval and remote playback
  • Recording download: Supports downloading historical recordings from devices
  • WebSocket notifications: Real-time push notifications for device status changes
Cargo.toml
[features]
gb28181 = ["dep:plugin-gb28181"]
gb28181:
enable: true
sip:
- domain: "3402000000"
domain_id: "34020000002000000001"
username: "34020000002000000001"
password: "your_sip_password"
digest_retry_limit: 2
digest_stale_retry_limit: 2
lan_ip: "192.168.1.100"
wan_ip: "203.0.113.1"
port: 5060
network: udp
rtp_port_min: 10000
rtp_port_max: 20000
heartbeat_timeout: 60
register_timeout: 300
download_storage_path: "./downloads"
download_retention_days: 7
OptionTypeDefaultDescription
domainstring"3402000000"SIP domain (administrative division code)
domain_idstring"34020000002000000001"SIP domain ID (20-digit code)
usernamestring?nullDigest auth username (optional)
passwordstring?nullDigest auth password (optional)
digest_retry_limitu82Max retries for normal 401 digest challenges
digest_stale_retry_limitu82Max retries for stale=true digest challenges
lan_ipstring"127.0.0.1"SIP LAN IP
wan_ipstring"127.0.0.1"SIP public IP (for NAT traversal)
portu165060SIP signaling port
networkstring"udp"Network protocol (udp or tcp)
OptionTypeDefaultDescription
enablebooltrueWhether to enable the plugin
rtp_port_minu1610000RTP media port range start
rtp_port_maxu1620000RTP media port range end
heartbeat_timeoutu6460Heartbeat timeout (seconds)
register_timeoutu64300Registration timeout (seconds)
download_storage_pathstring"./downloads"Recording download storage path
download_retention_daysi647Download file retention days

GB28181 device IDs follow a 20-digit encoding scheme:

Center code (8 digits) + Industry code (2 digits) + Type code (3 digits) + Sequence (7 digits)

For example: 34020000001320000001

  • 34020000: Administrative division code (Anhui Province)
  • 00: Industry code
  • 132: Type code (IPC camera)
  • 0000001: Sequence number
Device Monibuca (SIP Server)
| |
| -------- REGISTER ----------> |
| <------- 401 Unauthorized --- |
| -------- REGISTER (Auth) ---> |
| <------- 200 OK ----------- |
| |
| -------- Heartbeat(MESSAGE) -> |
| <------- 200 OK ----------- |
| |

On the camera or NVR’s GB28181 configuration page, fill in the following information:

ParameterValueDescription
SIP Server ID34020000002000000001Corresponds to domain_id in configuration
SIP Server Domain3402000000Corresponds to domain in configuration
SIP Server Address192.168.1.100Monibuca server IP
SIP Server Port5060Corresponds to port in configuration
Device ID34020000001320000001The device’s own 20-digit code
Transport ProtocolUDPCorresponds to network in configuration

Supported PTZ operations:

OperationDescription
Direction ControlUp, down, left, right, upper-left, lower-left, upper-right, lower-right
Zoom ControlZoom in, zoom out
Iris ControlOpen, close
PresetsSet, call, delete preset positions

PTZ control is invoked via HTTP API. See the GB28181 API documentation for details.

GB28181 devices can have multiple channels (e.g., an NVR with multiple cameras attached). Monibuca supports:

  • Automatic channel discovery (via Catalog query)
  • Independent live preview per channel
  • Independent PTZ control per channel
  • Real-time channel status updates

Monibuca can act as a lower-level platform, registering with an upper-level platform and pushing stream data:

Lower-level devices → Monibuca (Lower-level platform) → Upper-level platform

Cascading features include:

  • Registering with the upper-level platform
  • Responding to catalog queries from the upper-level platform
  • Pushing live streams to the upper-level platform on demand
  • Synchronizing device status changes

Query historical recording lists on device storage via GB28181 signaling, with support for filtering by time range and recording type.

Supports pulling historical recordings from devices for playback, including:

  • Normal playback
  • Fast forward / slow motion
  • Seek
  • Pause / resume

Supports downloading historical recordings from devices to local storage. Downloaded files are automatically saved to the configured storage path upon completion.

The GB28181 plugin provides a WebSocket interface for real-time device event push notifications:

const ws = new WebSocket('ws://localhost:8080/gb28181/ws');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('GB28181 event:', data);
};

Event types include: device online, device offline, channel update, alarm notification, etc.

Streams pushed by GB28181 devices can be played back through other protocols:

Terminal window
# Play device stream via HTTP-FLV
ffplay http://localhost:8080/flv/gb28181/34020000001320000001.flv
# Play via HLS
ffplay http://localhost:8080/hls/gb28181/34020000001320000001/index.m3u8
# Play via RTMP
ffplay rtmp://localhost:1935/gb28181/34020000001320000001

Deploying GB28181 services requires opening the following ports:

Terminal window
# SIP signaling port
sudo ufw allow 5060/udp
# RTP media port range
sudo ufw allow 10000:20000/udp