Following a really interesting thread on the chattyfig Flashcomm list I have now been able to put together a simple video player which is capable of requesting and playing parts of a flv video file that have not previously been downloaded.

This is a neat feature because it is usually only possible to play and seek to a part of a video that has already been downloaded unless you deploy a streaming media server.

Here's the working example. You need Player 8 for this but that's only because I encoded the video using VP6. The rest is compatible with Player 7.

I have uploaded my progress and included all sources.

It should be noted that due to the support of Buraks it was much easier to implement this idea. A new version of flvmdi injects an object containg two arrays into the flv's metadata. It contains the exact starting position in bytes and timecode of each keyframe. Using this information we can request any part of the flv file starting at a specified keyframe. Check this post for more info on flvmdi - the injection is NEEDED if you want the PHP seeking to work.

Thanks to everyone on the chattyfig list who contributed to this and also to Brian Bailey for blogging about his efforts. Thanks also to Lee Brimelow whose scrubber I have used and modified for this app.

*** UPDATE ***
I have made some small changes now:
- the 'buffering' no longer appears once the video has ended. This was done by simply introducing a new variable 'ending' and checking for a NetStream.Buffer.Flush message.
- loading bar shows the download progress again, although this is not that important as you can seek beyond that point anyway :-). But it will be good to further extend the app so that it will not request the file via PHP once it has loaded completely. We could seek normally once download is complete.
- source files have been updated

- another update (09/2007): updated sources by xmoov.com are now available at http://flashcomguru.com/downloads/phpstream_update.zip

UPDATE: Steve Savage has now ported this to Coldfusion: http://www.realitystorm.com/experiments/flash/streamingFLV/index.cfm

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 England & Wales License.