mod_flv

Description

mod_flv lets you stream .flv files in a way that flash players can seek into positions in the timeline.
Flash Player 8 and newer is required for seeking on the client-side.

A live demonstration of a flash streaming implementation can be seen at http://demo.lighttpd.net/flv/
Check the sourcecode there for further insight.

Setup Actions

none

Options

none

Actions

  • flv
    Enables .flv pseudo streaming for the current request and sets the Content-Type response header to "video/x-flv".
    Example: flv;

Example Configs

Minimal Config

This config will result in every request for a file whose name ends in ".flv" be handled as flash pseudo streaming.

setup {
    module_load "mod_flv";
}

docroot "/var/www";

if phys.path =$ ".flv" {
    flv;
}

With Throttling And Client-side Caching

This config will make browsers cache videos for 1 month and limit bandwidth to 150 kilobyte/s after 500 kilobytes.
The throttling can save bandwidth because people sometimes just check out the beginning of a video and then might decide to not watch it in whole.
To minimize unpleasant buffering at the beginning, an initial burst of 500 kilobytes is allowed to ignore the throttling.

setup {
    module_load ("mod_expire", "mod_flv");
}

docroot "/var/www";

if phys.path =$ ".flv" {
    expire "access 1 month";
    io.throttle 500kbyte => 150kbyte;
    flv;
}

Technical Details

flv will use the "start=OFFSET" query-string parameter to determine where to start "streaming" the static file; if the offset is valid and greater than zero, flv will prepend the FLV-header: "FLV\x1\x1\0\0\0\x9\0\0\0\x9".