By Paul
02/06/07 (Edited 09/04/09)
If your directory involves video content you may wish to convert it to FLV, to be embedded in a player using Macromedia's Flash plugin. Flash reaches a wider audience than WMV, QuickTime and the like and embeds more smoothly.
You have a switch in your switches to convert to FLV (it handles mov wmv avi mjpeg mpeg ogg), but you need to install some software and verify settings on your server first:
- PHP's shell_exec function must be enabled. Some shared hosts disable it.
- The upload_max_filesize value in php.ini must be set to something larger than the largest video file size you want to allow people to upload.
- lame must be installed
- ffmpeg must be installed
Ask your web host to do the above for you or give you instructions. Dreamhost has ffmpeg instructions here.
Optionally, in order to get meta-data set to allow skipping to particular spots in a video without loading the whole video, you can install ruby 1.8+ and flvtool2. Videos will convert to flv and play fine without them -- so don't worry about them if you have trouble.
Once you have everything installed you'll be able to convert files to FLV automatically on upload (when the switch is on). You can control the size of the resulting FLVs at Admin -> Settings -> Listings with the FLV resolution option there. Note the width and height must be multiples of 2 or ffmpeg will refuse to process it.
In order to play the movies WSN uses the now-dead Lovely Video Player 0.1. WSN Gallery has the playback built into the image details page, but in order to use it somewhere else or in another WSN script you can use this template code:
<IF {ATTACHEXTENSION} is flv>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="{FLASHWIDTH}" height="{FLASHHEIGHT}" id="ploneskin" align="middle" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="{DIRURL}/videoplayer.swf?video={ATTACHFLASHPATH}&autostart=0" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="{DIRURL}/videoplayer.swf?video={ATTACHFLASHPATH}&autostart=0" quality="high" bgcolor="#ffffff" width="{FLASHWIDTH}" height="{FLASHHEIGHT}" name="ploneskin" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</IF>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="{FLASHWIDTH}" height="{FLASHHEIGHT}" id="ploneskin" align="middle" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="{DIRURL}/videoplayer.swf?video={ATTACHFLASHPATH}&autostart=0" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="{DIRURL}/videoplayer.swf?video={ATTACHFLASHPATH}&autostart=0" quality="high" bgcolor="#ffffff" width="{FLASHWIDTH}" height="{FLASHHEIGHT}" name="ploneskin" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</IF>
Put it anywhere within the scope of an attachment and it'll show the player when it's an FLV.
Thumbnails for FLV work the same as for images (use {ATTACHTHUMBURL}). There's also a full-size preview image available which you can access via {ATTACHFLVPREVIEW}.
You can download the lovely player source code at http://scripts.webmastersite.net/wsnlinks/videoplayer.tar.bz2





