The Wiidiaserver

August 5, 2007

The Wiidiaserver is the servercomponent of the Wiidiaplayer. It has a number of jobs:

  • Serve over http the html page and the swf file that contain the clientside Wiidiaplayer (and the accompanying images in the near future)
  • Serve over http dynamic requests from the player on directory structure (this may change in the future to RTMP requests)
  • Stream the media file to the clientside Wiidiaplayer
  • (in the future) serve by http pictures for a slideshow.

The streaming of the media file happens over a RTMP connection. RTMP has only been reverse-engineered last year, and when I started on the Wiidiaplayer, only 4 implementations existed that I knew of. There is of course the official Adobe implementation, which will cost you at least a couple of thousand dollars to use, just as the Wowza Media Server. Then there is the Red5 server, which seemed like a lot of overkill, and since they hinted at their homepage that it would not be able to stream flash video yet, it didn’t seem worth the trouble to try. Then there was a implementation in HaXe. This last server actually had me streaming my first video within 5 minutes, however, although the idea behind HaXe is interesting, the language seemed too young. Furthermore, I didn’t like the idea of having to ask people to install apache and the Neko VM. Since the whole HaXe implementation was only a couple of hundred lines, I figured I could port it to twisted without too much trouble.

The Wiidiaserver has grown by now beyond the port of the HaXe code. Although the initial idea was to create a class that could be used in general RTMP projects in twisted, I gave up on it. For one, I don’t have enough experience with twisted to know what one would expect from such a class, but also, trying to develop a too general implementation only leads to more code, more bugs, more problems. Right now the RTMPy project is developing just such an implementation, in case someone is looking for it, and TAPE is a server developed on it (although, at the time of writing it doesn’t do video streaming yet)

The Wiidiaserver component is developing in a way specific to the Wiidiaplayer project. The FLV files that it streams coming from flv providers. These are classes that will get de FLV data from different sources. The simplest is a class that just serves an flv file that’s on disk. The more complicated ones create the flv file on the fly, and in the near future I’ll implement classes that will get the flv data from youtube, or a video4linux source. The server has extra functionality to handle such files. For instance, when seeking, it’s possible that the requested data is not available yet. It will then do repeated RTMP calls to the Wiidiaplayer to inform the client of the delay and how long it will take.

As with all: the server is in development, and might not be stable. The code can be found at . The server needs root-permissions to run, and will retain these while running (this will change in the near future as well). This is not advisable on any system, especially those connected to the outside world. Doing so is therefore obviously at own risk.

To run the server, you need python, twisted and twisted-web; converting makes use of mplayer(mencoder) for video and ffmpeg for audio.