Skip to content

Media Gateway Developer Guide

Andre Lafleur edited this page Dec 30, 2024 · 12 revisions

How to Access RTSP Video Streams

The URI format used for accessing live or playback streams via the Media Gateway is structured as follows:

rtsp://<username>:<password>@<authority>:<port>/<cameraId>/<stream>?<parameters>
  • username: (Optional) Security Center user credential.
  • password: (Optional) Password for the username.
  • authority: The Media Gateway server IP address or hostname.
  • port: The port number configured for the Media Gateway (default: 654).
  • cameraId: The GUID (Global Unique Identifier) of the camera.
  • stream: Specifies the stream type: live, playback, or any other configured streams (remote, highres, lowres).
  • parameters: Optional. Used for specifying playback options such as time range.

Live Streaming

For live streaming, the URI does not require parameters:

rtsp://<authority>/<cameraId>/live

Example:

rtsp://192.168.1.10:654/00000001-0000-babe-0000-00408ca1eb95/live

Some cameras may support additional streams, such as Remote, High Resolution, and Low Resolution.

  • Remote Stream:

    rtsp://<authority>/<cameraId>/remote
    
  • High Resolution Stream (HighRes):

    rtsp://<authority>/<cameraId>/highres
    
  • Low Resolution Stream (LowRes):

    rtsp://<authority>/<cameraId>/lowres
    

Ensure that these streams are supported and configured in your system.

Playback Streaming

Playback allows you to retrieve recorded video streams for a specific time range or from a specific start time.

Supported Parameters:

  • Range Header: The Range header specifies the time range for playback and supports absolute time-based playback using the clock format. It defines the start and, optionally, the end time for playback in UTC format (YYYYMMDDTHHMMSSZ). This parameter can be passed in two ways:

    • As a URL Parameter: Included in the URI to request specific playback ranges, such as:
      rtsp://<authority>/<cameraId>/playback?range=clock=<start>-<end>
      
    • As a Request Header: Included in the RTSP PLAY request as follows:
      Range: clock=<start>-<end>
      

Playback Options:

  • Playback of the Last Five Minutes (default):

    rtsp://<authority>/<cameraId>/playback
    
  • Playback Streaming from a Specific Time:

    rtsp://<authority>/<cameraId>/playback?range=clock=<start>
    

    Example:

    rtsp://192.168.1.10:654/00000001-0000-babe-0000-00408ca1eb95/playback?range=clock=20211208T083000Z
    
  • Playback Streaming with a Defined Time Range:

    rtsp://<authority>/<cameraId>/playback?range=clock=<start>-<end>
    

    Example:

    rtsp://192.168.1.10:654/00000001-0000-babe-0000-00408ca1eb95/playback?range=clock=20211208T083000Z-20211208T084000Z
    

    Note: If the end time is omitted, playback will continue from the start time until the configured maximum sequence length is reached, which defaults to 5 minutes.

The stream will begin at the following sequence if no sequence is available at the specified time.

Example RTSP Command for Playback:

PLAY rtsp://192.168.1.10:654/00000001-0000-babe-0000-00408ca1eb95/playback RTSP/1.0
CSeq: 3
Session: 12345678
Range: clock=20211208T083000Z-20211208T084000Z

Control the Speed and Direction Using the Scale Header

The Scale header in RTSP controls the playback speed of the media stream. It specifies a ratio indicating the speed at which the media should be played relative to its normal speed.

  • Positive Values: For forward playback.
  • Negative Values: For reverse playback.
  • Invalid Values: A scale value of 0 is invalid.
  • Keyframes: Reverse playback and speeds greater than 4x will only play keyframes.
  • Low Frame Rates: Streams recorded at extremely low frame rates may not play correctly.

Supported Scale Values:

Reverse Forward
-0.125* 0.125
-0.25 0.25
-0.333 0.333
-0.5 0.5
-1* 1
-2* 2
-4* 4
-6* 6*
-8* 8*
-10* 10*
-20* 20*
-40* 40*
-100* 100*

*Non-key frames will be removed from the stream.

Example RTSP Command for Scale:

PLAY rtsp://192.168.1.10:654/00000001-0000-babe-0000-00408ca1eb95/playback?range=clock=20211208T083000Z-20211208T084000Z RTSP/1.0
CSeq: 3
Session: 12345678
Range: clock=20211208T083000Z-20211208T084000Z
Scale: 2

Authentication

The Media Gateway optionally supports authentication. When this feature is enabled, credentials are required to stream video.


RTSP Authentication

  • User Credentials The username corresponds to a Security Center user, while the password must be set explicitly for the Media Gateway.
  • Privilege Requirement: User must have the "Log On Using SDK" privilege in Security Center to authenticate.

RTSPS Authentication

  • User Credentials: RTSPS connections require Security Center credentials (username and password).
  • Privilege Requirement: User must have the "Log On Using SDK" privilege in Security Center to authenticate.

Summary

Feature RTSP RTSPS
Authentication Optional Optional
Credentials Used Custom password for Media Gateway Security Center credentials
Encryption None TLS Encryption
Privilege Required "Log On Using SDK" privilege "Log On Using SDK" privilege