Configure SRT Streamid Parameter in FFmpeg

This article provides a concise guide on how to configure the stream identifier (streamid) parameter within a Secure Reliable Transport (SRT) URL using FFmpeg. You will learn the correct URL syntax for both simple identifiers and complex authentication strings, along with crucial tips for escaping special characters in command-line environments.

The streamid Parameter Syntax

In FFmpeg, the streamid parameter is passed directly as a query parameter within the SRT output destination URL. The generic syntax is:

srt://<host>:<port>?streamid=<identifier>

When invoking FFmpeg from a command-line interface, always enclose the entire SRT URL in double quotes to prevent the shell from misinterpreting query parameters (such as ?, &, or #).

Basic Usage Example

To stream a media file to an SRT listener using a simple alphanumeric identifier:

ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://192.168.1.50:9000?streamid=live_feed_1"

In this example:

  • -re reads the input at native frame rate.
  • -c copy avoids re-encoding the stream.
  • -f mpegts encapsulates the output into MPEG-TS format, which is the standard container for SRT.
  • streamid=live_feed_1 tells the receiving server which ingest channel to assign the stream to.

Complex streamid Format (Access Control & Routing)

Many SRT ingest servers (such as Haivision Media Platform, Nimble Streamer, or custom SRT relays) use a standardized key-value syntax for authentication and routing. This format typically follows the #!:: prefix:

#!::u=<username>,r=<resource>,h=<host>,m=<mode>

To use this structured format in FFmpeg:

ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://ingest.example.com:9000?streamid=#!::u=myuser,r=live/channel1,m=publish"

Handling Special Characters and URL Encoding

If your streamid contains characters that interfere with URL parsing or shell execution (such as spaces, semicolons, or ampersands), apply standard percent-encoding:

  • Space: %20
  • #: %23
  • &: %26
  • =: %3D

For example, if your destination server expects:

user=admin&token=secret123

Format the URL with encoding for the query separators:

ffmpeg -re -i input.mp4 -c copy -f mpegts "srt://ingest.example.com:9000?streamid=user%3Dadmin%26token%3Dsecret123"

Pulling a Stream Using streamid

The streamid parameter can also be applied when acting as a caller that reads from an SRT server:

ffmpeg -i "srt://ingest.example.com:9000?streamid=live/channel1" -c copy output.mp4