How to format Adobe Flash RTMP URLs

Many Flash-based players (FLVPlayback component being one) use a single RTMP URL to connect to the Wowza media server and to play a particular stream. In reality, this URL has two parts: server connection URL and stream name. The expanded format of this URL, assuming the stream is located at the path [path1]/[path2]/[streamName] takes the form:

rtmp://[wowza-ip-address]:[port]/[application]/[appInstance]/[prefix]:[path1]/[path2]/[streamName]
Where:
  • [wowza-ip-address]: Wowza media server domain name or IP address
  • [port]: TCP port to use for the connection (RTMP/RTMPE = 1935, RTMPT = 80, RTMPS = 443)
  • [application]: Application name
  • [appInstance]: Application instance name (defaults to _definst_)
  • [prefix]: Content type prefix (flv, mp4, mp3 - in Wowza Streaming Engine software, defaults to mp4 if omitted)
  • [path1]/[path2]/[streamName]: Stream path and name
If the stream name doesn't have path elements, the [appInstance] part can be omitted from the URL:
rtmp://[wowza-ip-address]:[port]/[application]/[prefix]:[streamName]
The important point here is that if the stream name has path elements, the full URL format must be used. In most cases this means adding _definst_ just after the [application] name.

Examples:

The following examples assume the Wowza media server is running at the domain name mycompany.com on TCP port 1935.

RTMP URL for application name vod and stream name mycoolvideo.mov

rtmp://mycompany.com/vod/mp4:mycoolvideo.mov
-or-
rtmp://mycompany.com/vod/_definst_/mp4:mycoolvideo.mov

RTMP URL for application name vod and stream name myvideos/mycoolvideo.mov

rtmp://mycompany.com/vod/_definst_/mp4:myvideos/mycoolvideo.mov
Note: The short form can't be used.

RTMP URL for application name vod and stream name myvideos/mycoolvideo.mov (with query parameters)

Because of the way most single URL players break apart the stream URL, any query parameters must be attached to the stream name and not the connection URL:
rtmp://mycompany.com/vod/_definst_/mp4:myvideos/mycoolvideo.mov?param1=value1&param2=value2
This means the query parameters aren't available in the onConnect handler. For example, the example URL above will most likely be broken into the server URL and stream name as follows:
Server: rtmp://mycompany.com/vod
Stream: mp4:myvideos/mycoolvideo.mov?param1=value1&param2=value2
The only place to intercept these query parameters is to override the play command. For example:
public void play(IClient client, RequestFunction function, AMFDataList params)
{
	String streamName = params.getString(PARAM1);

	String queryStr = "";
	int streamQueryIdx = streamName.indexOf("?");
	if (streamQueryIdx >= 0)
	{
		queryStr = streamName.substring(streamQueryIdx+1);
		streamName = streamName.substring(0, streamQueryIdx);
	}

	invokePrevious(client, function, params);
}

Originally Published: 10-01-2010.
 

If you're having problems or want to discuss this article, post in our forum.