Drupal 6 media streaming: Media Mover, FLV Media Player and XSPF Playlist
Having just completed building another Drupal media streaming website and I thought I'd take the time to share some of my experiences, especially seeing as two of my most popular articles are about Drupal and media streaming (Drupal 6 video streaming roundup and Drupal 6 media streaming with Dash Media Player). Things however, have come along a fiar bit since I wrote those articles.
The basic idea for this site was one that would allow administrators to upload videos, generate playlists from them, and provide an easy way for other people to embed these playlists in other webistes. The brief project went a little like this:
- User authentication (general public, site administrator, site developer)
- Personalised user home area.
- Multilingual capabilities (English and Spanish)
- Upload of videos in a wide variety of formats (videos to be converted to flash format for playback).
- Videos to be stored on and streamed back from Amazon S3 server.
- Categorisation of videos.
- Video playlist for each video category.
- Dynamic 'most played' video playlist.
- Per user 'custom' playlist (users of the site may generate their own playlist).
- For each video, the following options must be available on the site:
- play (plays the video from a flash player embeded on the site).
- more info (displays the full description of the video).
- embed (provides html embed allowing users to embed the video in their own website).
- add (adds the video to the users custom playlist).
- Customised embeddable flash player (2 versions – horizontal style and vertical style).
This site presented several problems, many of which could be solved by using existing modules out of the box, others would take a bit more work...
Building a media streaming workflow
On-top of all the usual gubbins (Administration menu, FCKEditor, IMCE, Transliteration, all the multilingual stuff etc etc) there is a small handful of modules that provide a very special set of functionality, which when combined, give the ability to create a very advanced media streaming workflow.
I'm talking about accepting video in a huge array of formats (avi mov wmv mpeg mp4 mpeg2 dv 3gp 3g2 mpeg4 and more), automatically converting them to other formats (.flv in our case), generating thumbnails of various sizes, storing them on remote servers, building playlists and embedding them into a web page for playback! Yes, all that is possible, and with fairly minimal effort considering.
Media Mover
First, there is Media Mover - this really is a diamond. Media Mover is a set of modules which allows website administrators to easily create complex file conversion processes. The core of Media Mover is the media_mover_api module which creates a set of rules allowing multiple modules to interact with a file. Media Mover can harvest media files from a variety of sources (email, ftp, cck fields, etc.), turn these files into FLV files (or any other format), create new nodes with the file data attached, and then save the files on an external file storage system like Amazon's S3 all at once.
FFmpeg Wrapper
The bulk of the work that is performed by Media Mover is made possible with this helper model, that provides access to the FFmpeg application. It provides some basic functionality for developers who need to process media files. In addition to transcoding media, FFmpeg Wrapper provides a way to extract specific data from a media file - duration, dimensions, codec, etc. Exactly what we need. Media Mover is designed to work in combination with FFmpeg Wrapper. The main hurdle with FFMpeg Wrapper is actually setting up the ffmpeg libraries on your webserver - but I'll leave that for another article.
FLV Media Player
This is a helper/configuration module to work with JW media player FLV flash player - possibly the most popular and one of the most flexible flash players out there. FLV Media Player makes it simple to embed the JW player in a web page (with the help of the SWFObject API module). It works by allowing you to configure one or more player profiles, each of which defines an instance of a player - its size, skin, playback settings etc. These player profiles can then be associated with nodes or nodes node types in order to display a player for any media attached to a node. They can also be used at the theme layer allowing for a great deal of flexibility.
XSPF Playlist
XSPF Playlist generates a playlist file in the standard XSPF format from files that are attached to a piece of content. It is designed for smooth integration with FLV Media Player and has support for Views allowing a vast array of playlists to be generated from site content.
Creating user playlists
One of the main selling points of this website was the ability for users to be able to generate their own playlists. They should be able to browse the site, and when they see a video they like, they can add it to their own playlist with a click of the mouse. This functionality is provided by the folowing pair of modules.
Flag
Flag is a flexible flagging system that is completely customisable by the administrator. Using this module, the site administrator can provide any number of flags for nodes, comments, or users. Some possibilities include flagging content as important, offensive or as a bookmark. With extensive Views integration, you can create custom lists of popular content or keep tabs on important content. You can probably see how this suits my goals.
Draggable Views
DraggableViews makes rows of a view "draggable" which means that they can be rearranged by drag'n drop. This module makes it possible to organise complex structures (e.g. project-trees, nodes on frontpage,..) with just a few clicks. Now this is the module that brings an extra level to the user generated playlists. With this, they can use simple drag and drop to reorder their playlists... Nice!
Some custom magic
While all of the above modules are great, as with most sites, they require a little custom magic if they are to be able to perform their functions the way that our site dictates. A lot of this is simple stuff at the theme layer, and the rest required a small custom module which provides small enhancements and overrides to the various modules listed above.
Problems encountered
One of the main problems I faced was the fact that many of these modules were still in their early stages of development. This means bugs, lots of them... To give you an idea what I'm talking about, here is a list of bugs that I encountered:
-
more fine grained permission - limiting who can access the embed code.
-
Broken player from generated embed code (fullscreen doesn't work)
-
Extract code that parses configuration paramters into its own function
-
Better Views support in xspf_playlist_views (omit playlist item attributes from the playlist)
I found myself having to debug and fix the majority of these bugs myself, though the module maintainers were generally pretty responsive and helpful too, which always helps. Now for me, this isn't a problem - actually, this is what I enjoy doing. However, for other people, debugging and fixing issues like these may simply not be possible and may prove to be a real sticking point.
Conclusion
When it comes to building a media platform, Drupal is really starting to shine. And, it is quite clear that there are a great number of people out there who are willing and able to continue to improve this situation. Media Mover, XSPF Playlist and FLV Media player provide a very powerful and flexible solution that can be tailored to suit your particular needs with fairly minimal effort.
If I had to build another media streaming website (and it's looking like I will very soon!) I would almost certainly use Drupal again.
Now, if you want to see the actual site that I built - www.crescentmedia.tv

Comments
Post new comment