wiki:Mod-H264-Streaming

H264 Streaming With Lighttpd

back

mod_h264_streaming is based on an already existing lighttpd module (mod_flv_streaming by Jan Kneschke). The basics are very similar and this module allows you to seek in MP4 files.


* This page is obsolete, a newer version and up to date documentation is available. You most likely want to go to the new version.*


Examples

The module expects a URL which matches h264-streaming.extensions and that can handle a '?start=" part of the request.

Testing

The start position is given in seconds. So for example to request an MP4 file starting at forty-five and half a second from the beginning you would pass ?start=45.5

For testing purposes we recommend a tool like WGET. So:

wget -O test.mp4 http://h264.code-shop.com:8080/trailer2.mp4?start=45.5

saves a file (test.mp4) on your local disk that will have the first 45.5 seconds removed from the original (trailer2.mp4) file. You can use your favorite player to see if worked okay.

Query parameters

parameter namevaluenotes
startstart time of video clip (in seconds)defaults to start of clip
endend time of video clip (in seconds)defaults to end of clip
clientFLASHwhen the client is specified as FLASH meta data will not be compressed and only 1 video and audio stream is returned

Virtual video clips

As you can see it is easy to create 'virtual video clips'. Let's say that you have a *very* long video that you do not want to re-encode into smaller parts, you can easily specify them using the start and end times.

So there is only one full clip stored, but parts of it can be made available, like so:

The full cliphttp://h264.code-shop.com:8080/workers_world_co64_box64.mp4?start=0
The first minutehttp://h264.code-shop.com:8080/workers_world_co64_box64.mp4?start=0&end=60
The last two minuteshttp://h264.code-shop.com:8080/workers_world_co64_box64.mp4?start=404

Flash

The information to pass into the ‘start’ parameter is extracted by the flash-player from the meta-data of the mp4-files. Note that you pass it the 'time' field and not the 'offset' field.

var url = "http://h264.code-shop.com:8080/trailer2.mp4?start=" + metadata.seekpoints[keyframe]["time"];
NetStream.play(url)

Metadata

You have to make sure that this meta-data is present in the video stream. See Encoding for more information on how to encode videos.


Lighttpd config

server.modules = ( 
  ...,
  "mod_h264_streaming",
  ...
)
h264-streaming.extensions = ( ".mp4" )

Note that if you are using mod_secdownload to prevent hotlinking of your mp4 files that it is included before the mod_h264_streaming in the module list.

Last modified 6 years ago Last modified on 02/05/09 23:28:43