Lighttpd
上QQ阅读APP看书,第一时间看更新

Streaming Content

There are different solutions for streaming flash videos. Dedicated streaming servers, an apache module, and different CGI-backend-based solutions have sprung up. Of course, Lighttpd plays this game, too, with mod_flv_streaming. The configuration is as simple as it gets:

# add mod_flv_streaming to our module list
server.modules = (..., "mod_flv_streaming", ...)
# set a list of extensions to stream
flv-streaming.extensions = ( ".flv" )

That's it. Now we need a player that works with our streaming protocol. Fabian Topfsted has written such a player, and has made it available for noncommercial purposes at http://www.topfstedt.de/weblog/?page_id=208. The site has everything we need to know about setting up and embedding the player into our pages.

Apart from that, we need to be sure that our videos have the metadata (byte position of the first frame in the file, kilobytes per second, and so on) embedded in the beginning. For flash video, which keeps a constant bitrate, the playing position can then be set freely. H.264 video, which has variable bitrates, can only be played from start to end.

There are some tools to convert videos to the flv format and change the metadata:

  • MPlayer/MEncoder at www.mplayerhq.hu is a fairly minimal player/encoder combo that is quite fast and plays or encodes almost everything with a minimal user interface and lots of command line options.
  • yamdi (short for "Yet Another MetaData Injector for FLV") is a command line tool to inject metadata to FLV files. It is pretty fast, because it reads only what it needs. Download it from http://yamdi.sourceforge.net.
  • FLVTool2, located at http://inlet-media.de/flvtool2 is another utility for FLV metadata. FLVTool2 is written in Ruby, and is thus platform-agnostic. It may not be the fastest tool, but it does the job.
  • FLVMDI is a Windows-based tool with a GUI that sets and shows FLV metadata. The homepage at http://www.buraks.com/flvmdi has the documentation and the downloads.

This is it. We can now go and build our own YouTube. Or whatever site we may want to enhance with FLV streams.