Convert RTSP/RTMP to PS Stream

A complete guide to transform RTSP or RTMP streams into PS (Program Stream) format using Happytime GB28181 Device. Essential for GB28181 platform integration and video surveillance systems.

Understanding PS Stream and Its Importance

A Program Stream (PS) is a container format defined by the MPEG standard, commonly used in DVD-Video and, crucially, in the GB28181 national standard for video surveillance and networked systems in China.

Converting an RTSP or RTMP stream to a PS stream is a critical step for:

  • GB28181 Platform Integration: Most GB28181-compliant platforms require video streams in PS format.
  • ONVIF to GB28181 Transcoding: Bridge devices often convert ONVIF/RTSP streams from IP cameras to PS streams for GB28181 platforms.
  • Standardized Surveillance: Ensures compatibility and interoperability within a standardized video surveillance ecosystem.

This guide shows you how to use Happytime GB28181 Device to seamlessly convert various input sources into PS streams.

Configuration Overview

Configure the conversion by editing the gb28181device.cfg file. Each <channel> node represents a single video source that will be converted to a PS stream.

Basic Channel Configuration

gb28181device.cfg
<channel>
    <cid>34020000001310000001</cid>
    <cname>Front Gate Camera</cname>
    <media_url>rtsp://192.168.1.3/live</media_url>
    <!-- Other parameters... -->
</channel>

Key Parameters:

  • <cid>: The unique channel ID (Device ID in GB28181).
  • <cname>: The human-readable channel name.
  • <media_url>: The input source. This is where you specify your RTSP/RTMP stream or other data source.

Supported Input Sources (<media_url>)

The <media_url> parameter defines the input source for the channel. It supports a wide range of inputs, categorized below:

1. Stream Media Inputs
  • filename: Local media file (e.g., video.mp4).
  • rtsp://... Streaming media from an RTSP server (e.g., rtsp://ip:port/stream).
  • rtmp://... Streaming media from an RTMP server (e.g., rtmp://ip:port/app/stream).
  • http://...mjpeg Streaming media from an MJPEG server.
2. Local Capture Devices
  • screenlive: Capture video from the computer's screen.
  • videodevice: Capture video from the first connected camera.
  • audiodevice: Capture audio from the first connected audio device.
  • videodeviceN: Specify camera by index (e.g., videodevice1 for the second camera).
  • audiodeviceN: Specify audio device by index (e.g., audiodevice1 for the second mic).
3. Combined Inputs
  • screenlive+audiodevice: Screen video + audio from the default audio device.
  • videodevice+audiodevice: Camera video + audio from the default audio device.

Complete Configuration Example

A full gb28181device.cfg setup for converting an RTSP stream from a camera into a PS stream for GB28181.

gb28181device.cfg
<channel>
    <cid>34020000001310000002</cid>
    <cname>Rear Yard Camera</cname>
    <media_url>rtsp://admin:password@192.168.1.50:554/Streaming/Channels/101</media_url>
    <!-- Other GB28181 parameters... -->
</channel>

Best Practices

  • Use RTSP for Cameras: For IP cameras, RTSP is the most common and reliable protocol to use as input.
  • Include Credentials: If your RTSP/RTMP stream requires authentication, embed the username and password in the URL (e.g., rtsp://user:pass@ip:port/stream).
  • Verify Stream Address: Ensure the RTSP/RTMP URL is correct and accessible from the server running Happytime GB28181 Device.
  • Device Indexing: When multiple cameras are connected, use videodeviceN to precisely select the desired source.
  • Test Incrementally: Start with one channel and verify the PS stream output before adding more.