Getting video and audio streams

Get real-time video streams using the TRASSIR SDK as follows:

  1. A stream request command, containing the following mandatory parameters is sent to the server:

    channel - The channel's GUID;

    stream - The type of stream being requested:

    • main - The main stream;
    • sub - The auxiliary stream;
    • archive_main - The archive of the main stream;
    • archive_sub - The archive of the auxiliary stream.

    container - The format of the ingoing stream:

    • flv - The stream in Flash format;
    • jpeg - The stream in the form of a single frame in JPG format;
    • mjpeg - The stream in MJPEG format;
    • rtsp - RTSP stream;
    • rtmp - RTMP stream;
    • hls - HLS stream;
    • custom - The audio stream.

    sid - The unique session ID.

    You can also add optional parameters to the command:

    quality - stream compression quality from 0 to 100% for JPG (container=jpeg) and MJPEG(container=mjpeg).

    framerate - for MJPEG(container=mjpeg) flow rate (from 0 to 60000):

    • 0 - Real-time stream;
    • 60000 - One frame per minute speed.

    audio - for RTSP (container=rtsp) enable audio stream alongside with the video stream (audio=pcmu).

    hw - boolean parameter containing archive request from the device:

    • true - in the device archive stream;
    • false - in TRASSIR archive stream.
  2. In response, the server issues a unique Token that is used to form the final string to receive the audio or video stream.

Tip

You can find the channel's GUID using the request for the object tree /objects, or using the quick command to request the channel list /channels.

Important

Note that all commands related to receiving video: /channels, /archive_status, /archive_command, and /get_video, must be executed using a session obtained under any user (NOT using an SDK password).

Examples of the Token request from the channel=CKq5LLiO channel:

  • receiving mainstream (stream=main) at rate of 1 frame per second (framerate=1000), decoded into MJPEG format (container=mjpeg) with 80% compression quality (quality=80):

    https://192.168.1.200:8080/get_video?channel=CKq5LLiO&container=mjpeg&quality=80&stream=main&framerate=1000&sid=WP6IRcrQ   
  • receiving RTSP stream (container=rtsp) of the substream (stream=sub):

    https://192.168.1.200:8080/get_video?channel=CKq5LLiO&container=rtsp&stream=sub&sid=WP6IRcrQ   
  • receiving the archive of the mainstream (stream=archive_main) decoded in MJPEG (container=mjpeg):

    https://192.168.1.200:8080/get_video?channel=CKq5LLiO&container=mjpeg&stream=archive_main&sid=WP6IRcrQ   
  • receiving audio (container=custom) of the mainstream (stream=main):

    https://192.168.1.200:8080/get_video?channel=CKq5LLiO&container=custom&stream=main&sid=WP6IRcrQ   

Example of a server response:

    {
        "success" : 1,
        "token" : "c4Z0qkuu"
    }  

In this example, the response contains:

  • "success" : 1 - the authorization was successful;
  • "token" : "c4Z0qkuu" - the unique Token for the requested video;

Examples of the requests to receive video and audio streams:

  • of the main and substreams and their archives:

    http://192.168.1.200:555/c4Z0qkuu   
  • of the RTSP stream

    rtsp://192.168.1.200:555/c4Z0qkuu   
  • stream in HLS:

    https://192.168.1.200:8080/hls/c4Z0qkuu/master.m3u8   
  • of the audio stream:

    http://192.168.1.200:555/media/c4Z0qkuu?stream=audio&container=ogg&channels=2&bitrate=64000&samplerate=44100   

In these examples the request contains:

  • c4Z0qkuu - The Token received previously;
  • stream=audio - Send the audio stream;
  • container=ogg - The audio stream's codec (aac or ogg);
  • channels=2 - The number of channels in the audio stream being sent;
  • bitrate=64000 - The level of audio compression;
  • samplerate=44100 - The audio stream's sampling rate (8000, 11025, 16000, 22050, 24000, 32000, 44100 or 48000).

Important

The life span of the Token is 10 seconds and it "deceases" in the absence of constant requests. To prolong its life span during pause while reviewing an archive or watching videos of high framerate, you should execute the following query:

http://192.168.1.200:555/c4Z0qkuu?ping  

Important

Receiving the archive stream is executed by the following algorithm:

  1. Make Token request with the container=archive_main or container=archive_sub parameter.
  2. Execute the stream inquiry via Token.
  3. With archive management commands set the playback starting point and start the playback.

Tip

Note that the stream is transmitted using http (http:// appears at the front of the IP address) over port 555 (you can change the port in the server settings). To receive the stream on RTSP protocol, rtsp:// is typed at the front of the IP address and 555 port is also used.