Tips for streaming video with Amazon CloudFront + Flowplayer

Reynold Greenlaw

Flowplayer is a Flash-based video-player that supports streaming video using the Adobe’s Real-Time Messaging Protociol (RTMP). Amazon CloudFront is a content-delivery network (CDN) tied in with Amazon’s Simple Storage Service (Amazon S3), and can stream via RTMP. Great! This is a simple-to-set-up, cost-effective, and reliable video-on-demand system.

Where you can get a little bit tangled up is the way the video resource is identified to the player. Following the recipe for Flowplayer with the RTMP plug-in, you need two values, the url property of the clip, and the netConnectionUrl of the plug-in. The second of these is the URL of the streaming distribution from CloudFront with /cfx/st added to the end, as in rtmp:// .

The clip’s url property is based on its Amazon S3 object key.  The instructions in Amazon’s developer guide says mysteriously:

To serve MP3 audio files or H.264/MPEG-4 video files, you might need to prefix the file name with mp3: or mp4:. Some clients can be configured to add the prefix automatically. The client might also require you to specify the file name without the file extension (e.g., magicvideo instead of magicvideo.mp4).

Some experimentation indicates that with Flowplayer you add the mp4: prefix and can omit the .mp4 suffix. Also when they say ‘file name’, they mean the whole object key, including any slashes. So if the clip is stored on S3 as foo/bar.mp4, then the clip’s url property is mp4:foo/bar.