So, I want to stream my own video, from my own server? Why would I want to do that? Control, I guess. It cna be argued that there are enough sites around already that can host videos for you (Youtube, Flickr, et al), and it makes sense to eat into their bandwidth rather than your own, but let’s just see – can it be done using Open Source tools?

Enter Red5

Red5 is an Open Source Flash video streaming application. It is written in Java and serves the same purpose as the very expensive Adobe Flash Media Server.

Before I take it for a test run, it is worth looking at the Red5 hall of fame. Noteworthy is openmeetings, which – if it supports video – could fill a niche that clients often ask for.

In the next part I will install the server and run some tests.

————————

The next part is going to take a little longer than I expected. The installation instructions start with “download the source code, you will need Eclipse too…”. So my idea of ‘just installing, trying and tweaking’ goes out the window at the first step. It may take an hour to set up, it may take three days – that’s the way with Linux and Java, and I just don’t have the time to take a risk just to see how well something is going to work.

If anyone knows of a packaged version of Red5 that I can simply drop onto a non-GUI Linux server and run, I’d love to know.

————————

But Do I Really Need Streaming?

This is the point at which a realisation that I have been chasing the wrong horse hits me. I have been imaginging that YouTube is streamed to the browser. It turns out it is not. It is delivered in pseudo stream through HTTP, which is probably one of the main reasons for its success, since HTTP gets through firewalls without a thought.

So, to deliver Flash videos from a website, and allow the user to fast-forward to any point in that video, only a simple PHP script is needed. The PHP script will start streaming, byte-by-byte, the Flash video file from any given point. The Flash player then handles the rest; it just makes GET requests: give me the file X starting at byte Y; keep going until I break the connection.

The xmoov-php script here can deliver this stream, and there is an associated xmoov FLV player that hooks up to it. At the time of writing, the player has not been released, so it is difficult to take it for a test-run. However, the JW FLV Player supports the same protocol and that is available under an Open Source licence for non-profit organisations (though check out the definition of ‘non-profit’ before assuming your organisation counts as one), or under a commercial licence for a small and reasonable fee. As a bonus, the player now supports true RTMP streaming, as provided by the Red5 server.

Having tried to get this player working, I am having some Java troubles am waiting for a response to my bug report.

————————

‘bug’ fixed: it turns out the FLV file needs metadata added to it to list where all the keyframes are. The FLVMDI tool does that nicely by scanning the file and inserting the metadata. Once the FLV video was post-processed to add this metadata, the whole pseudo-streaming worked like a dream.

The demo can be seen here. Try to random-access parts of the video; it works. What would be a nice addition would be for the player to cache each downloaded section and be able to piece them together. At the moment it will cache just one segment of the video, and you can seek to any point within that cache, but if you click outside of it (i.e. after the current loading point or before the segment starting point) then the cache is thrown away completely, forcing the player to start downloading – quite possible – the whole segment again.

————–

See also ffmpeg FLV converter.