Monday, March 3, 2008

[Flash] Flow Player and video random access


Problem: handle random access to a FLV (Flash Video) file using FlowPlayer flash player.

Solution: this article is a sort of How To about how to make random access working using this particular flash palyer (that is open source and well working).

What is random access?
Essentially random access can be seen in most of YouTube videos: you don't have to buffer the entire video, because it's possible to select a specific instant to play that has not been buffered yet!

Simply, but of course it didn't mean to work...

I had to work with already coded FLV files, using ffmpeg (if I'm not wrong they came from a MPEG4 video and MP3 audio). Anyway I haven't never worked with FLV files, but I found them very very interesting; in fact it's possibile to write MetaData just inside the file.
Anyway FlowPlayer, from its site, grants the possibility of random access, so it was not a player's fault if my videos didn't work with random access.

After a full day of searching, finally a flash of knwoledge: there is a free tool, called FLVTool2 that puts inside the file constant metadata to mark up each instant (I suppose it is done each half second or more or less), so random access depends on those markups (and so it is not continous).
To make it possibile this is one of the possibile usage of the tool (inserts meta data in an output file and after the process visualizes metadata content of the file):
flvtool2 -UP inputVideo.flv outputVIdeo.flv

Of course output file is not needed.

This is not all: random access wasn't still working!

After some reading (one inside the FlowPlayer site I haven't seen at first sight) I found the problem: if you want random access you must use a streaming server.
Just this?? What's the problem, sure you can find billions of free streaming server...

Well , yes, there are a lot of them but all in beta or even alpha release, so in my opinion they were not worth for business applications.

Fortunately a google (I love you) result came to save me: Flash Streaming to FlowPlayer using only PHP!!
In few words, using a script linked in that page, you set up a PHP Streaming Server (it simply sends via HTTP the video from the point selected with FlowPlayer) that works very well: I don't know how it is scalable, but in my tests the streaming was fluid and in time.

So if you have my same problem and don't want to spend hundreds of euros to buy a professional streaming server, this is your solution!

And remember, you are never alone: google is always next to you with a confortable word!

No comments: