Extension:FlvHandler

What can this extension do?
This extension adds support for using Flash video (.flv) files in exactly the same way as images are normally used, i.e. .  This allows users to upload Flash videos and add them to articles using a method they are already familiar with.

Usage
Once uploading of .flv files has been permitted, Flash videos can be uploaded and then embedded in an article page in the same manner as with images:



Features
Features which make this extension stand out from other .flv extensions:


 * .flv files can be uploaded and displayed like any other image
 * .flv files can be categorised and thumbnails of the video shown on category pages (just like with ordinary images)
 * An image gallery can include .flv files

Requirements

 * 1) ffmpeg: This extension uses ffmpeg to extract the first frame from the video file, for use as a thumbnail.  If you do not have the command-line ffmpeg binary available on your web host, you will not see any preview frames.  You will however still be able to embed videos, but your site visitors will not know what the video is until they start playing it.
 * 2) flowplayer: This extension uses the GPL'd flowplayer Flash applet to play the FLV files.  A future version will probably extend this to include other players as well (especially if someone sends me the HTML code to embed a particular player.)
 * 3) File uploads must already be working on your wiki.  If not, see Manual:Configuring file uploads.

Download

 * 1) Download FlvHandler-r3.zip and extract it into the   directory in your MediaWiki installation.
 * 2) Download flowplayer v3.0.3 and unzip it into   or alternatively set   to the URL of flowplayer's .swf file.  If you do not use flowplayer version 3.0.3 you will need to set   as the default will point to the wrong filename version (see below.)
 * 3) Add the following to LocalSettings.php:

Configuration parameters
All these parameters are optional, and suitable defaults are selected if omitted.


 * - URL of the flowplayer .swf file. Default is
 * - Minimum size of the playback window. Default is   (250 pixels wide by 250 pixels tall) which is about as small as flowplayer will go before the controls start being drawn on top of each other.
 * - program to use to extract first frame of video for thumbnails. Default is   (currently the only available option.)
 * - Path to conversion binary (ffmpeg executable) if not in the system path.

How it works
If you're writing an extension and you think you might get some clues from how FlvHandler is written, then read on - this section briefly explains how the extension does its job.

There are two parts to the extension. The first is an image handler, which registers itself in the same way as the SVG handler. The idea of an image handler is to convert an unsupported image format into one that is widely supported (usually .png). Whenever a request comes through to display the .flv file, the handler steps in, calls FFmpeg to generate a thumbnail of the video (if one hasn't already been created), and then returns that thumbnail in .png format. This thumbnail is then displayed as requested. If this was the only part of the plugin in use, then .flv files would appear everywhere as still images. It is this part of the plugin that allows .flv files to be used anywhere images are, such as in categories and image galleries. It is also this part of the plugin which relies on FFmpeg being available to generate the thumbnails.

The second part of the plugin uses the ImageBeforeProduceHTML hook to step in whenever an image is about to be rendered in an article (read: whenever an tag is about to be printed.) If the image tag is a thumbnail (or not a Flash video) then further processing is cancelled, and the tag is rendered as per normal (and in the case of a thumbnail, the other part of the plugin takes over and generates a still frame as the thumbnail.)  If instead the image is a Flash video, then the extension takes over and generates the HTML code necessary to embed the flash player in the page.

To do
This is a list of things planned for the extension that aren't currently there:


 * Support for multiple Flash playing applets (only flowplayer is currently implemented)
 * Extra code around the embedded player so that there is a link to the .flv's article page (like what happens when you click on an embedded image, and you are taken to the image's article page.)
 * Preview on the .flv's article page, so you can watch the video from there (currently you have to embed it in a page before you can watch it.)
 * Support for some of the flash player's tags (abstracted so it works with any flash player) - e.g. autostart
 * Ability to specify (in the Image tag) which frame to use as the thumbnail - currently it is hard-coded as the first frame