Friday, February 1, 2008

Self-hosted Flash Video

Nowadays, the easiest way to upload videos to the web is via Google Video, YouTube, Metacafe, Vimeo, and the like.

If, for some reason, you want to host your videos on your own server, here are 4 steps to easily do this in Linux:

  1. Convert your video using ffmpeg:
    ffmpeg -i your.avi -s 320x240 your.flv

  2. Grab JW FLV Media Player and extract mediaplayer.swf

  3. Upload your FLV file and mediaplayer.swf to your server.

  4. Edit your HTML file to include something like this (one line):

    <embed src="mediaplayer.swf" allowfullscreen="false" allowscriptaccess="always" flashvars="&amp;file=your.flv&amp;autostart=false" height="240" width="320"></embed>

    or the more standards-compliant

    <object type="application/x-shockwave-flash" data="mediaplayer.swf" width="320" height="240">
    <param name="allowfullscreen" value="false" />
    <param name="allowscriptaccess" value="always" />
    <param name="flashvars" value="&amp;file=your.flv&amp;autostart=false" />

    Note that the latter is not viewable in the Nokia Internet Tablets.

You should end up with something like this:

Hosting your own videos allows you to avoid any branding that a third-party host might impose -- perfect for intranet/corporate use. You should also check out the various features, such as playlists, that JW FLV Media Player offers.