As of SWF Tools 6.x-2.x there is early support for streaming media from Flash Media Servers (such as Adobe's Flash Media Server, Red5 open source server, or Wowza).

This page is only partial at the moment, but it is intended to provide something of a reference guide if you want to experiment with the features. Note that setting up a media server can be tricky, and this page can't really help you out with that part - it is intended to help you use SWF Tools with a working media server!

At present, streaming media is support in the Wijering 4 and FlowPlayer 3 modules. Both can handle single media streams, whilst FlowPlayer3 can also handle streamed playlists.

The examples below show how to stream media using the swf filter syntax, and an example for PHP is also provided as it can be a little bit confusing as to where to pass the various parameters.

[swf] input filter

In summary, all you need to do is add the parameter stream="rtmp://server/application" to your regular [swf] string. Because for the media servers you don't always include the extension, or you might be streaming a format other than flv, you should also tell SWF Tools to treat the file as a video stream by setting action="swftools_flv_display" or action="swftools_flv_display_list".

The best way to understand it is with some examples...

To stream a single flv video file:
[swf file="sample" stream="rtmp://server/app" action="swftools_flv_display"]

Note that the extension is not included on the filename for an flv stream.

To stream a single f4v:
[swf file="mp4:myVideo.f4v" stream="rtmp://server/app" action="swftools_flv_display"]

Note in this case that the file type is specified by the prefix mp4:, and the extension is included.

To stream a media playlist (FlowPlayer3 only):
[swf files="videoOne&&videoTwo" stream="rtmp://server/app" action="swftools_flv_display_list" playlist="true"]

You can even pick up a live video stream. For example, using the included live service with Flash Media Server you can use

[swf file="cameraFeed" stream="rtmp://server/live" action="swftools_flv_display" live="true" player="flowplayer3_mediaplayer"]

or

[swf file="cameraFeed" stream="rtmp://server/live" action="swftools_flv_display" type="rtmp" player="wijering4_mediaplayer"]

Be aware that FlowPlayer3 will not play back flv files that DO NOT include metadata in their header. If you're not sure then open the flv in a text editor or hex editor. If you can see some plain text metadata titles at the start of the file it should be ok. If all you see is hex with nothing sensible in plain text then the metadata is probably missing and the file will not play in FlowPlayer3, or it may play just the audio stream.

PHP

You can also stream via PHP and it uses the same parameters as above. The only difference is that you need to pass the parameters via the optional arguments array when you call swf() [see the swf() documentation for more details]. It might not be immediately obvious how to do this, so the following example shows the format to use.

The key information is that stream goes in the othervars array, action goes in the methods array which is also part of othervars, and type (used by Wijering) is a flashvar.

Knowing that then the proper PHP format would be

print swf('sample',
          array(
            'flashvars' => array('type' => 'rtmp'),
            'othervars' => array('stream' => 'rtmp://server/app', 'methods' => array('action' => 'swftools_flv_display')),
          )
        );

Comments

emackn’s picture

The files i want to stream are not located on my server, but with a caching provider. How can that be handled?

Also, Whenver I give swf() a file of '/any/path/file.m4v', when i view the source output, only 'file.m4v' shows up for the 'file' param. Is there anohter option Im forgetting to set? I'm already setting $othervars with stream and methods, and adding type to flashvars.

cientista’s picture

Hi,

Thanks so much for the swftools module. I have Flowplayer 3.0.7 displaying flv files nicely from my server. However, I just signed up to MaxCDN and I'm having trouble getting it to work from the CDN. I get the following error message:-

202, The provider specified in this clip is not loaded, Provider 'stream, '[Clip] 'vod/cientista,capoeirascience/butterfly-twist.flv"

Here is the page and syntax I'm using, is there something I have configured incorrectly? I added the flowplayer RTMP plug-in flowplayer.rtmp-3.1.3.swf to the same folder as flowplayer.-3.0.7.swf

swf file="vod/cientista.capoeirascience/butterfly-twist.flv" stream="rtmp://vod01.netdna.com/play" action="swftools_flv_display"
http://www.capoeirascience.com/max%20cdn%20test

On another note does swftools support pseudostreaming to a CDN?

Any help much appreciated.
Thanks,
Andy