Creating a HTML5 Video Extension for MediaWiki
Another bit of random coding from Fuzzy Tolerance.
I have a wiki page where I put a lot of tutorial videos for our division. Some are hosted on YouTube because they are about something general or about something related to one of our open source projects. But some are just for the locals and I don’t want them to live on YouTube for various reasons. I’ve been wanting to try a little HTML5 video, and this seemed like a good opportunity.
I hunted through the MediaWiki extensions, but I couldn’t find what I was looking for. I looked through the MediaWiki extension docs and made a quick and dirty HTML5 video extension.
Nothing magical here:
- I put a videos folder in my mediawiki directory and put videos in ogv and mp4 formats there (same video name for both, different extensions). There's lots of stuff you can use to convert video files. I used Transmageddon on linux, but you can always just use ffmpeg.
- Toss a flash video player in that folder as well for IE users. I used JW Player.
- Make a folder called html5vid in your MediaWiki extensions folder. Save the above code in that folder as html5vid.php.
- Add the line require_once('extensions/html5vid/html5vid.php'); to your LocalSettings.php file to enable the extension.
- In a wiki entry, drop in . Just the video file name without extensions.
Writing extensions for MediaWiki is really easy. Especially if they’re fairly lousy and bereft of features like this one :). One thing to note - Firefox will not stream video if the MIME type from the server is incorrect. For Apache, drop this in your config file:
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
Thanks to this site for saving me a few hours of skull-to-desk.