/

SRT Restreaming


With release 7.1.0, SRT restreaming (BETA) only works on Ubuntu 18. It is not supported on CentOS or Ubuntu 16.

Please see Ubuntu setup document for requirements. In addition, you will need to enable SRT by modifying red5pro/conf/restreamer-plugin.properties, setting enable.srtingest=true.

For SRT streaming, you must run the API command first, and then start your stream. By default, you have 2 minutes (12000 milliseconds) after running the command to start your stream. If you want to extend that time, modify red5pro/conf/srt-ingest-plugin.properties socket.idle.timeout= value.

SRT also requires an encrypted passphrase, which is set for each stream via the API call. The default encryption is set to a 16-byte keylength (128-bit encryption), but this can be configured to use 24 or 32-length as well.

Supported parameters sent via the API call

  • frameType - The type of encapsulation utilized for the data (audio, video, etc) traversing the network

    • 0 - MPEG-TS
    • 1 - EFP (Elastic Framework Protocol)
  • latency - TsbPd receiver delay (mSec) to absorb burst of missed packet retransmission. The time that should elapse since the moment when the packet was sent and the moment when it’s delivered to the receiver application in the receiving function. This time should be a buffer time large enough to cover the time spent for sending, unexpectedly extended RTT time, and the time needed to retransmit the lost UDP packet.
  • reorder - Maximum possible packet reorder tolerance (number of packets to receive after loss to send lossreport)
  • overhead - Recovery bandwidth overhead above input rate. A Maximum bandwidth ceiling based on % over input stream rate.
  • keyLength - Cryptographic key length in bytes

    • 0 = PBKEYLEN not set, crypto disabled
    • 16 = AES-128
    • 24 = AES-192
    • 32 = AES-256
  • passphrase - Crypto PBKDF2 Passphrase size [0,10..64] (0 = disable); for 128-bit encryption the passphrase must be at least 16 characters

Additional information about the parameters:

SRT Stream Create

Description

Add SRT stream

REQUEST

  • URI: https://{hostname}/live/restream
  • Method: POST
  • Parameters:
{
    "guid": "live/stream1",
    "context": "live",
    "name": "stream1",
    "level": 0,
    "parameters": {
        "type": "srt",
        "action": "create",
        "ip": "0.0.0.0",
        "port": 8001,
        "frameType": 0,
        "latency": 100,
        "reorder": 16,
        "overhead": 100,
        "keyLength": 16,
        "passphrase": "samplePassphrase"
    }
}

SRT Stream Kill

Description

Stop the SRT stream

REQUEST

  • URI: https://{hostname}/live/restream
  • Method: POST
  • Parameters:
{
    "guid": "live/stream1",
    "context": "live",
    "name": "stream1",
    "level": 0,
    "parameters": {
        "type": "srt",
        "action": "kill"
    }
}

Test SRT Streaming with ffmpeg

How to test SRT with an MP4 file via ffmpeg.

NOTE: unless you modify the timeout in red5pro/conf/srt-ingest-plugin.properties, you will have 2 minutes (12000 milliseconds) from when you post the API call to start the stream; if you wait longer then you will need to re-create the stream via the API (you can also change that value by modifying socket.idle.timeout= value)

1 - Create the SRT stream by running the API call (note: make sure the ports match between the API call and the ffmpeg command)

POST: https://(server).red5.org/live/restream

{
    "guid": "live/stream1",
    "context": "live",
    "name": "stream1",
    "level": 0,
    "parameters": {
        "type": "srt",
        "action": "create",
        "ip": "0.0.0.0",
        "port": 8000,
        "frameType": 0,
        "latency": 100,
        "reorder": 16, 
        "overhead": 100,
        "keyLength": 16,
        "passphrase": "Red5ProRules2020"
    }
}

2 - Start the stream via ffmpeg:

ffmpeg -re -stream_loop -1 -i TESTFILE.mp4 -c:v libx264 -b:v 5000k -bsf:v h264_mp4toannexb -profile:v baseline -level:v 3.2 -x264-params keyint=120:scenecut=0 -c:a aac -b:a 128k -ar 44100 -f mpegts "srt://YOUR-SERVER-IP:8000?pkt_size=1316&mode=caller&minversion=0x010300&latency=100000&oheadbw=100&transtype=live&pbkeylen=16&passphrase=Red5ProRules2020"

3 - Go to the subscribe page and refresh. You should see the stream listed.