Monday, January 16, 2012

Embedding Videos in #Moodle 2.2

Images Adapted from: and
Although, by this time, the advice in this blog entry is second-nature to me, especially since I first wrote about it in regards to Moodle 1.9.x, it's still a question that pops up periodically:
How do you embed video in Moodle?
This blog entry shares one approach that can be accomplished in 3 steps:
  1. Turn on Multimedia Filters
  2. Allow embedding of third party code
  3. Modifying your PHP.ini file to allow larger file sizes.
And, of course, there's a 4th possibility that's optional for low-tech folks who may not be able to edit their PHP.ini file.

To display HTML5 Video/Audio, MP4, AVI, WMF, MPG, SWF, FLV and other video formats easily just enable your Multimedia Plugins. 

To accomplish that, go to SITE ADMINISTRATION->PLUGINS->MANAGE FILTERS in your Moodle 2.2x site as shown below:

Find the greyed out Multimedia Plugins and turn them ON:

Then click on the SETTINGS and adjust them as follows:

If you plan to embed videos from sources like YouTube/Vimeo or elsewhere, you will want to make one more modification in your SITE ADMINISTRATION->SECURITY->SITE POLICIES:

Then, scroll down and enable these settings as shown below:

Making this change will allow you to embed content from other sources that have the EMBED CODE button.

If you want to embed your own video, you can also use this sample embed code here -
Note that I've had mixed results with this embed code; it works with SWF, but probably not with other video formats. 
Here is a screenshot:

Another solution for embedding video that works quite well is JWPlayer:
  1. Download JWPLAYER, a free Flash video player and put it on your server in a directory somewhere that's easy to link to.
  2. Use this embed code (copy-n-paste the code into HTML block while in HTML view) replacing the the 2 links. The first link goes to the location of JWPlayer's "player.swf" file and the second link to your video
  3. Try it out!
I like JWPlayer quite a bit...well worth trying out.

One final adjustment you will want to make. Often, video files are quite large. Uploading them to a Moodle 2.2 site may mean putting video files that are 50 megs or more on the server. To upload such large file sizes, you will certainly need to adjust the PHP.ini file on your server:

To find the PHP.ini file on an Ubuntu server, look here:

and then make the following adjustments:
post_max_size = 2000M
mysql.connect_timeout = -1
max_execution_time = 5000
max_input_time = 5000
memory_limit = 500M

file_uploads = On
upload_max_filesize = 2000M

Note that 2000M is the equivalent of 2gigs, far more than you should be trying to upload. I like to have space to play, however. Feel free to adjust the actual amount to whatever you deem appropriate. If you're going to be placing a lot of videos in your Moodle course, I recommend considering #4 alternative below. The reason why is that uploading videos into your Moodle instance will "balloon" the size of the Moodle instance, which can be a pain when making a backup of a course)

If you don't have access to your PHP.INI file, then I would recommend you use a video hosting service (e.g. YouTube, Vimeo Plus for $60 annual cost). I've investigated lots of alternative video-hosting providers and keep coming back to these two as great solutions. Whether they will work depends on your environment (e.g. in some school districts, YouTube is blocked).

If neither of these is an option, you have another approach you can take that involves you hosting your videos in a server directory. This approach means that you have some way to get videos onto the server, and it could take any one of the following approaches:
  • A mapped drive/directory that allows you to link to the videos. Note that the "drive mapping" really needs you to be able to have access to a folder on the web server that is accessible via the Web. You 
  • FTP rights to a video folder where you're going to store content. The FTP approach will allow you to upload your files to a server directory, then use the absolute link so that you don't end up embedding lots of videos in your Moodle.
  • Use PMWiki Storage Approach outlined below:
PMWiki Solution: PHP only wiki, no MySQL needed--has a great self-hosted wiki solution that would work as a video repository without having to grant anyone FTP rights. I use PMWiki when I need a simple, non-MySQL-based wiki.

With the addition of a few add-ons to PMWiki, I had a simple solution that allowed end users to access a single page, upload their documents, images, whatever, but that they had to login to. It looks like this:
Reflecting on this solution, I'm reminded about how important it is to be aware of the capabilities of all the tools in your arsenal. . .implementing this solution--training the end users--was FAR easier than the Moodle solution I jumped to. And, Moodle was only arrived at extensive efforts at customizing SFTP settings.

 If you're interested in this approach, let me know! I can bottle up a PMWiki all setup and share that so you can save yourself some PMWiki configuration work.

UPDATE - Comment from Jon Fila (

Jon Fila shared this in an email (my apologies to those who have trouble leaving comments):
Hi Miguel, I just read your blog post on embedding video in Moodle 2.2:
I've had some trouble with that so that it would display in all browsers on all devices. I tried to leave a comment on your blog but the presence of my HTML tags didn't work so well.
Feel free to spread this if you find it works:
It's difficult to embed videos from a file in a way that will work in every browser on all devices. One thing I've done is to make sure my video's dimension (I use MP4 so they're iPad accessible) for width is around 800 or less. Also, I've been changing the embed code

This was the only way I could get it to show up in FireFox; Chrome; IE; Safari on PC & Mac.
I hope that makes sense,

Get Blog Updates via Email!
Enter your email address:
Delivered by FeedBurner

Everything posted on Miguel Guhlin's blogs/wikis are his personal opinion and do not necessarily represent the views of his employer(s) or its clients. Read Full Disclosure


Helen Foster said...

Thanks for this informative blog post, Miguel. Hope it's OK with you to link to it from the docs

Miguel Guhlin said...

Helen, if you want to use any of my stuff, you are always welcome!! No need to ask, although it's nice to know when you link.

With appreciation for all your work and that of fellow Moodlers,


Miguel Guhlin said...

Jon Fila's comment--which he sent via email--has been embedded into the blog post as an update since the comment engine can't accept the HTML code he sent with it.

Thanks, Jon!

Nadav Kavalerchik said...

Another safe way to embed videos in Moodle 2.x is to use:

< object type="text/html" data="http://video-url" ... >

< object type="text/html" data="" style="height: 360px; width: 640px; border: 0; overflow: hidden;">

Miguel Guhlin said...

@Nadav, thank you!!

Nadav Kavalerchik said...

You are welcome :-)

btw, I enjoyed your post very much.

And just found out that i can paste IFARME embed code from YouTube directly, anywhere, into HTML code in Moodle 2.2
I did not tweak it and i am sure it was not possible, on early versions, especially since i made a video tutorial how to circumvent it. funny. can you confirm this too?

Frank Erazo said...

Not sure if my first attempt at a post was successful, so forgive me if you see it twice.

I want to take advantage of HTML5 and Moodle. How would I embed the code?

-Frank Erazo

gillboucher said...

Thank you for the info! However, in the section, "Another solution for embedding video that works quite well is JWPlayer:"... the embed code link doesn't seem to be working. Would love the code!!!

Thank you!!

~ Gillian B

gillboucher said...

Thanks for the info! However, in the section "Another solution for embedding video that works quite well is JWPlayer:"... the 'embed code' link doesn't seem to be working?

I would love the code! Thank you!

~ Gillian B.

Anonymous said...

Embed videos using the JWPlayer in Moodle 2.2 is not working, by using the File upload (I'ts the only possibility we have)
The link looks like:
It’s also not working if I encoding this URL...
Does anybody have a solution for that?

Anonymous said...

Does some one know if it's possible to set the align of the video to "left"? When I use the MoodleMedia-FlowPlayer-Workfow the Player is alwas in the middle of the site.

Thanks Roo

Jimi said...

Nicely done! Muchas Gracias!

The Courage to Lead