Overview
Happytime GB28181 Device supports capturing the computer's desktop screen, a specific application window, or a designated monitor and pushing it as a GB28181-compliant PS (Program Stream) to any GB28181 platform. This capability eliminates the need for external capture hardware and is particularly useful for:
- Remote Operations Monitoring: Stream real-time industrial HMI or SCADA screens to a centralized surveillance center.
- Training & Demonstration: Share your desktop or a specific application as a live video feed within a GB28181 monitoring platform.
- Command & Dispatch Centers: Integrate PC-based data dashboards directly into the video wall via the GB28181 protocol.
- GIS & Mapping Systems: Broadcast live maps and situational awareness displays to GB28181-compliant clients.
This guide walks you through configuring the gb28181device.cfg file to enable desktop or window capture as a GB28181 video channel.
Supported Screen Capture Modes
The <media_url> parameter within each <channel> configuration accepts the following screen capture values:
| media_url Value | Description | Example |
|---|---|---|
screenlive |
Capture the entire primary display. | Default single-monitor setup. |
screenlive+audiodevice |
Capture the primary display along with system audio from the default audio device. | Screen sharing with audio narration. |
screenliveN |
Capture a specific monitor identified by its index N, where N starts from 0 for the first display. screenlive0 is equivalent to screenlive. |
screenlive1 for the second monitor in a multi-display setup. |
window=[window name] |
Capture only a specific application window whose title matches the given name. This allows you to stream a single program without exposing the rest of the desktop. | window=Notepad, window=Google Chrome. |
Note: When using window=[window name], the window title must match exactly. If multiple windows share the same title, the first match is selected. Keep the target window open and visible (not minimized) to ensure capture works correctly.
Step 1: Prepare the Configuration File
Locate the gb28181device.cfg file in your GB28181 Device installation directory. Open it with a text editor and ensure the global SIP registration parameters are correctly set for your GB28181 platform.
Below is a reference for the global configuration section:
<config>
<version>2016</version>
<server_ip>192.168.3.36</server_ip>
<server_port>5060</server_port>
<server_id>34020000002000000001</server_id>
<server_domain>3402000000</server_domain>
<local_port>0</local_port>
<device_id>34020000001110000001</device_id>
<device_name>Happytimesoft</device_name>
<password>12345678</password>
<protocol>udp</protocol>
<media_protocol>tcp</media_protocol>
<reg_expires>3600</reg_expires>
<heartbeat_interval>10</heartbeat_interval>
<heartbeat_count>0</heartbeat_count>
<media_base_port>19000</media_base_port>
<log_enable>1</log_enable>
<log_level>1</log_level>
<log_path></log_path>
<log_mode>loop</log_mode>
<log_max_size></log_max_size>
<log_max_index></log_max_index>
<!-- Channel configurations go here -->
</config>
Replace <server_ip>, <server_id>, <server_domain>, <device_id>, and <password> with the values provided by your GB28181 platform administrator.
Step 2: Configure a Channel for Screen Capture
Add a <channel> block inside the <config> element with <media_url> set to the desired screen capture mode.
Example 1: Capture the Entire Primary Screen
<channel>
<cid>34020000001310000001</cid>
<cname>Desktop Screen</cname>
<media_url>screenlive</media_url>
<ondemand>1</ondemand>
<output>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>G711A</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
<bitrate></bitrate>
</audio>
</output>
</channel>
Key channel parameters:
<cid>: Unique channel ID registered on the GB28181 platform.<cname>: Human-readable channel name displayed on the platform.<media_url>: Set toscreenlivefor primary display capture.
The <output> block allows you to override video and audio encoding parameters. Leaving a field empty (or 0) tells the engine to use the original source resolution, framerate, or automatically calculate the bitrate.
Step 3: Capture a Specific Monitor (Multi-Display)
If your system has multiple monitors, append the display index after screenlive. The index is zero-based, meaning:
screenlive0— First monitor (same asscreenlive)screenlive1— Second monitorscreenlive2— Third monitor
Example 2: Capture the Second Monitor
<channel>
<cid>34020000001310000002</cid>
<cname>Monitor 2</cname>
<media_url>screenlive1</media_url>
<ondemand>1</ondemand>
<output>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>G711A</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
<bitrate></bitrate>
</audio>
</output>
</channel>
Step 4: Capture a Specific Application Window
To stream only a single application window without exposing the entire desktop, use the window=[window name] format. Replace [window name] with the exact window title text.
Example 3: Capture a Notepad Window
<channel>
<cid>34020000001310000003</cid>
<cname>Notepad Window</cname>
<media_url>window=Notepad</media_url>
<ondemand>1</ondemand>
<output>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>G711A</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
<bitrate></bitrate>
</audio>
</output>
</channel>
Tips for window capture:
- The target window must be open and not minimized. If the window is closed or minimized, the stream will stop or show a blank frame.
- Use the exact window title as it appears in the title bar. For example, if the browser tab changes the title, the capture may fail to match.
- For applications with dynamic titles (e.g., browsers showing page titles), consider using
screenliveinstead, or isolate the application on a dedicated monitor and usescreenliveN.
Step 5: Complete Multi-Channel Configuration Example
Below is a full gb28181device.cfg configuration that registers two screen capture channels on a single GB28181 device, along with complete SIP and logging settings:
<config>
<version>2016</version>
<server_ip>192.168.3.36</server_ip>
<server_port>5060</server_port>
<server_id>34020000002000000001</server_id>
<server_domain>3402000000</server_domain>
<local_port>0</local_port>
<device_id>34020000001110000001</device_id>
<device_name>Happytimesoft</device_name>
<password>12345678</password>
<protocol>udp</protocol>
<media_protocol>tcp</media_protocol>
<reg_expires>3600</reg_expires>
<heartbeat_interval>10</heartbeat_interval>
<heartbeat_count>0</heartbeat_count>
<media_base_port>19000</media_base_port>
<log_enable>1</log_enable>
<log_level>1</log_level>
<log_path></log_path>
<log_mode>loop</log_mode>
<log_max_size></log_max_size>
<log_max_index></log_max_index>
<channel>
<cid>34020000001310000001</cid>
<cname>channel1</cname>
<media_url>screenlive</media_url>
<ondemand>1</ondemand>
<output>
<video>
<codec>H264</codec>
<width></width>
<height></height>
<framerate></framerate>
<bitrate></bitrate>
</video>
<audio>
<codec>G711A</codec>
<samplerate>8000</samplerate>
<channels>1</channels>
<bitrate></bitrate>
</audio>
</output>
</channel>
</config>
Step 6: Launch and Verify
- Save the
gb28181device.cfgfile. - Run the GB28181 Device executable. The application will read the configuration, register with the SIP server, and start listening for stream requests.
- Check the logs (enabled via
<log_enable>1</log_enable>) to confirm successful SIP registration. Look for log entries indicating the device has registered successfully at the configured<server_ip>. - On your GB28181 platform, locate the device by its
<device_id>and initiate a live preview. The platform should receive the PS stream containing your desktop or window content.
Output Parameter Tuning
The <output> section within each channel allows you to control encoding quality. Adjust these parameters based on your network bandwidth and quality requirements:
| Parameter | Description | Recommendation |
|---|---|---|
<codec> |
Video codec: H264, H265, or MP4. |
Use H264 for maximum platform compatibility; H265 for reduced bandwidth. |
<width> / <height> |
Output resolution in pixels. Leave empty to use the original screen resolution. | Set 1920 x 1080 if you need to limit bandwidth on high-DPI displays. |
<framerate> |
Output frame rate in fps. Leave empty to use the original refresh rate. | 15 or 25 for screen capture; higher values consume more bandwidth. |
<bitrate> |
Video bitrate in kb/s. If 0, calculated automatically. |
2048 for 1080p screen content; increase for detailed text or rapid UI changes. |
<samplerate> |
Audio sample rate in Hz. | 8000 for G711; 44100 for AAC. |
<channels> |
Audio channels: 1 for mono, 2 for stereo. |
1 for voice; 2 for multimedia content. |
Troubleshooting
| Issue | Possible Cause | Resolution |
|---|---|---|
| Stream shows a black screen. | The target window is minimized or the display is off. | Ensure the window is open and visible; check that the monitor is powered on. |
| Window capture does not match. | Window title contains hidden characters or has changed. | Copy the exact window title from the title bar. Use Task Manager to verify the process name matches. |
| High CPU usage during capture. | Screen resolution or framerate is too high. | Lower <width>, <height>, or <framerate> in the <output> section. |
| Registration fails on the platform. | Incorrect server IP, port, or device credentials. | Verify <server_ip>, <server_port>, <device_id>, and <password> with your platform administrator. |
| No audio in the stream. | screenlive captures video only. |
Use screenlive+audiodevice to include system audio. |
Best Practices
- Use Separate Channels for Independent Sources: Configure a distinct
<channel>for each monitor or window to keep streams organized and independently accessible. - Set a Descriptive Channel Name: Use meaningful
<cname>values (e.g., "Control Room Screen", "GIS Dashboard") to help platform operators identify streams quickly. - Test Before Deployment: Run a single-channel setup first to verify that SIP registration, media transport, and video quality meet your requirements before scaling to multiple channels.
- Monitor Log Output: Keep
<log_enable>enabled during initial setup to quickly diagnose configuration issues. Disable or reduce log level in production to minimize disk I/O. - Limit Framerate for Static Content: If streaming dashboards or text-heavy applications, a framerate of
10-15is usually sufficient and saves significant bandwidth.