Delivering Video From Moodle

HTML5-logo.svgA recent request and a lack of media server has meant that I have needed to look at delivering video from within Moodle.

Moodle provides a media filter that recognizes links to videos and automatically embeds them in a page, which means from a user perspective they just need to upload a video and Moodle does all the hard work. Also since 2.0ish the media filter has provided an option to use HTML5 embedding which is used by modern browsers such as everything that is not IE.

It is possible to upload different versions of a video and let the automatic embed feature work out which is best. This can be done using a complicated process of seperating video urls with # such as the sample below which offers 4 video formats that in theory should cover all possible browsers.

<a href="">Film Clip</a>

Whilst this does work it can only be achieved by editing the HTML source which is beyond most users capabilities (and providing 4 version of the same video!).

After testing I found that MP4 can be used for most browsers with an FLV file as a fallback. This seemed better than having to create OGV and WebM formats but would still require two videos and editing of HTML.

After a bit of detective work I discovered that the flash video player used by Moodle, called Flowplayer, is capable of playing MP4 files but this feature is not used by Moodle. I also discovered that the HTML5 detection code will see if the browser supports MP4 natively and if not fall back to the other alternative in Moodle, by default Quicktime (but could in theory be Flowplayer).

So with some minor changes to core code it would be possible to deliver MP4 video to all browsers. A user could just upload an MP4 video then Moodle will do the rest by either using HTML5 video tags for Chrome, Safari and mobile devices or Flowplayer for other devices.

To achieve this is really easy and just requires two minor changes to core Moodle code.
First you should open up moodle/lib/medialib.php and locate the section for using Flowplayer, which is the class core_media_player_flv.
Within this class (approx. line 719) change…

public function get_supported_extensions() {
    return array('flv', 'f4v');


public function get_supported_extensions() {
    return array('flv', 'f4v', 'mp4', 'm4v');

which means Flowplayer is used for MP4 and M4V video formats.

Next locate the HTML5 video class called core_media_player_html5video.
Within this class (approx. line 1104) change…

public function get_rank() {
    return 20;


public function get_rank() {
    return 90;

Which means that the HTML5 video embed is used ahead of the FLV embed (and now MP4 embed), which itself is used ahead of Quicktime.

That is all that is required. Because it is so simple I have raised this as a suggestion in Moodle Tracker at

Enhanced by Zemanta

One thought on “Delivering Video From Moodle

Leave a Reply

Your email address will not be published. Required fields are marked *