Wowza Community

RTMP single url format (server url and stream name combined into single url)

Many Flash based players (FLVPlayback component being one) will use a single RTMP url to both connect to Wowza Media Server and play a particular stream. In reality this url is broken into two pieces; 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-or-domain]:[port]/[application]/[appInstance]/[prefix]:[path1]/[path2]/[streamName]

Where:

  • [wowza-ip-or-domain]: Wowza Media Server domain name or ip address

  • [port]: Is the 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 - defaults to flv if omitted)

  • [path1]/[path2]/[streamName]: Stream path and name

    If the stream name does not contain any path elements, then the url can be shortened to (omitting [appInstance] part):

    rtmp://[wowza-ip-or-domain]:[port]/[application]//[prefix]:[streamName]
    
    

    The important point here is if the stream name contains path elements then the full url format must be used. In most cases this means adding definst just after the [application] name.

    Examples:

    (these examples assume the Wowza server is running at the domain name mycompany.com on TCP port 1935)

    If application name is vod and stream name is mycoolvideo.mov then the rtmp url is:

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

    If application name is vod and stream name is myvideos/mycoolvideo.mov then the rtmp url is:

    rtmp://mycompany.com/vod/_definst_/mp4:myvideos/mycoolvideo.mov
    
    

    Note: The short form cannot be used.

    Note: Another issue are the query parameters that are attached to a url such as:

    rtmp://mycompany.com/vod/mp4:mycoolvideo.mov?param1=value1&param2=value2
    
    

    Because of the way most single url players break apart the stream url, the query parameters will be attached to the stream name and not the connection url. For this reason the query parameters will not be available in the onConnect handler. For example the url above will most likely be broken into the server url and stream name as follows:

    Server: rtmp://mycompany.com/vod
    Stream: mp4: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);
    }
    
    

    Charlie

Hi there:

I stumbled across this thread while trying to debug an issue, and have a question.

ActionScript offers a couple of ways to play audio – via Sound/SoundChannel and via NetStream. The Flash application we’ve written has been developed using a regular ol’ HTTP server to serve up the audio, with Sound/SoundChannel as the client. For example:

mySound.load(new URLRequest(“http://mycompany.com/myfile.mp3”));

However we’ve had no luck using this method for connecting to the Wowza server to stream the files using an RTMP-prefixed URL in place of the HTTP URL.

Your thread suggests this is possible, though. Is it? We’d prefer to avoid rewriting the application to use NetStream if possible, since we’ve already written everything using Sound/SoundChannel. Is it possible to connect to a Wowza audio stream using just a URL and Flash’s Sound and SoundChannel classes?

Thanks in advance!

Chris

No, sorry, you have to use NetConnection and NetStream in Flash client to stream from Wowza Server.

Richard

You cannot use rtmp resource this way. Put the file on web server and use http url. If it is on the same web server as the player you can use relative url.

var req:URLRequest = new URLRequest("myAudioFile.mp3");

Richard

Is this still valid or can we use flash.media.Sound object to connect to wowza?

This is the code:

s = new Sound();

var req:URLRequest = new URLRequest(“rtmp://wowza-ipaddress/vod/mp3:myAudioFile.mp3”);

var context:SoundLoaderContext = new SoundLoaderContext(5000, true);

s.load(req, context);

I’m getting this error: Security error: #2000 no active security context