Go
Not registered? Sign up!

RTMP Streaming with the JW Player

Google Translate
RTMP Streaming with the JW Player

The JW Player fully supports playback of videos through the RTMP protocol. Adobe's Flash Media Server, Wowza's Media Server and Red5 can be used. A quick RTMP example can be seen in the setup wizard here. Compared to regular playback of FLV videos, there are a few caveats to keep in mind though. They are explained here.

Streamer

For playback of a regular FLV video, only the flashvar file is needed. This flashvar tells the videoplayer where the video is located on the internet. If this is the path to the video:

http://www.mywebsite.com/path/to/video.flv

The corresponding flashvar would be:

file=http://www.mywebsite.com/path/to/video.flv

For playback of RTMP videos, the path of a certain video contains two important values instead of one. First, there's of course the path of the video. Second, there's the location of the RTMP application that is streaming the video. Example:

rtmp://www.mywebsite.com/path/to/application/path/to/video.flv

Since the JW Player cannot automatically detect which part of the URL is the RTMP application and which part of the URL is the video, you MUST split up your path into a file and a streamer flashvar. The streamer tells the player the location of the RTMP application:

streamer=rtmp://www.mywebsite.com/path/to/application&file=path/to/video.flv

File Extension

In the documentation of FMS or Wowza you'll find some directions on how to load and play different filetypes in actionscript. They recommend that:

  1. FLV video is loaded without the .flv extension.
  2. MP3 audio is loaded with the mp3: prefix.
  3. MP4 audio/video is loaded with the mp4: prefix.

This however, is NOT needed with the JW Player. You can simply give the filepath to your video to the file flashvar, without any modifications. The player itself will internally make those changes. So:

  1. FLV video is loaded with file=path/to/video.flv.
  2. MP3 audio is loaded with file=path/to/audio.mp3.
  3. MP4 audio/video is loaded with file=path/to/video.mp4 or file=path/to/audio.m4a (or file=path/to/video.mov or file=path/to/audio.aac ...).

If you do NOT specify an extension at the end of the file flashvar, the player will not know of which filetype the video is. By default, it will then presume you load a playlist! So make sure you always include the extension. If you cannot use an extension, for example if you use a token security:

streamer=rtmp://www.mysite.com/application&file=video?12rwfwdsf23grss

Then you can use the additional type flashvar to tell the player that the file definitely is a single rtmp video:

streamer=rtmp://www.mysite.com/application&file=video?12rwfwdsf23grss&type=rtmp

Playlists

Besides single files, you can also play playlists of RTMP streams. There are two options for that. First, if all your videos come from the same server, you only have to define the streamer as a flashvar. The player will automaticaly use the RTMP application to stream all videos in the playlist. Here's the setup for the flashvars:

streamer=rtmp://www.mysite.com/application&file=http://www.mysite.com/path/to/playlist.xml

And the playlist will then be something like:

    <playlist version="1" xmlns="http://xspf.org/ns/0/">
        <tracklist>
            <track>
                <title>The first video</title>
                <location>path/to/first.flv</location>
            </track>
            <track>
                <title>Second video in the list.</title>
                <location>path/to/second.flv</location>
            </track>
            <track>
                <title>And the final one.</title>
                <location>path/to/third.flv</location>
            </track>
        </tracklist>
    </playlist>

Second, there is also the option to assign the streamer flashvar to individual playlist entries, so you can mix different RTMP streamers, or even streaming and non-streaming content, in one playlist. This feature has only been introduced in the 4.3 player though, so make sure you have a recent copy. The flashvars then don't need a streamer:

file=http://www.mysite.com/path/to/playlist.xml

And the playlist includes the streamer where needed:

    <playlist version="1" xmlns="http://xspf.org/ns/0/">
        <tracklist>
            <track>
                <title>The first video is not streamed</title>
                <location>http://www.mysite.com/path/to/first.flv</location>
            </track>
            <track>
                <title>The second video is streamed</title>
                <location>path/to/second.flv</location>
                <meta rel="streamer">rtmp://www.mysite.com/application</meta>
            </track>
            <track>
                <title>The last video uses a different streamer</title>
                <location>path/to/third.flv</location>
                <meta rel="streamer">rtmp://www.someothersite.com/other_app</meta>
            </track>
        </tracklist>
    </playlist>

These examples used the XSPF playlist format. The entries to use for all other playlist formats can be found in the overview of supported playlists.

Live Streaming

Live streaming using RTMP should work just like on-demand streaming for RTMP. The player will automatically detect the stream is live, and it will not tick the elapsed/remaining time or show the scrubber.

For most live stream setups, the extension of the video cannot be .flv, so here too you must add the additional &type=rtmp flashvar to tell the player to process a live stream.

JW FLV Player

JW FLV Player Download the world's most popular open source player. It supports FLV, MP3, MP4 & AAC; it's Plugin-extensible; and it's fully integrated with our AdSolution. No wonder it's #1.

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!