Moodle

Add support for mp4 and m4v to filters

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.4
  • Fix Version/s: 1.9.7, 2.0
  • Component/s: Filters
  • Labels:
    None
  • Environment:
    Moodle 1.9.4+ (20090320)
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE, MOODLE_20_STABLE

Description

Hi all,

it should be easy to install the support for mp4 and m4v into the Moodle Multimedia Filter. Both formats could be played with QuickTime on Mac OS X and Windows XP/Vista. I met Martin at the MoodleMoot 2009 in Bamberg/Germany and he fixed the problem for mp4 on my own MacBook.

It would be good if the coding will be implemented into the official Moodle 1.9.5. YouTube started to use mp4. The video iPods are using mp4 and m4v.

Best regards, Ralf

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Hi Ralf,

agree we should be able to do that... can you point me, please to some mp4/m4v sources? If so, I'll try to do my best. Also, I think the hacked filter in your MacBook could be a good point of start, if you can attach it here...

About YouTube using mp4 for iPods/iPhones... that's true... but I don't think those files are available publicly, in their servers, or perhaps yes? Doesn't affect the main thing of the bug, in any case, just a side comment.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - Hi Ralf, agree we should be able to do that... can you point me, please to some mp4/m4v sources? If so, I'll try to do my best. Also, I think the hacked filter in your MacBook could be a good point of start, if you can attach it here... About YouTube using mp4 for iPods/iPhones... that's true... but I don't think those files are available publicly, in their servers, or perhaps yes? Doesn't affect the main thing of the bug, in any case, just a side comment. Ciao
Hide
Andy Kemp added a comment -

As the multimedia plugin is broadly based around the JW player it should be possible to update the player (which now supports H264) and alter the filter to use the player for these files...

Show
Andy Kemp added a comment - As the multimedia plugin is broadly based around the JW player it should be possible to update the player (which now supports H264) and alter the filter to use the player for these files...
Hide
Andy Kemp added a comment -

As a quick temporary fix though you can add the following lines to relevant section in filter.php:

if ($CFG->filter_mediaplugin_enable_mov) {
$search = '/<a.*?href="([^<]+\.mp4)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);
}

if ($CFG->filter_mediaplugin_enable_mov) {
$search = '/<a.*?href="([^<]+\.m4v)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);
}

As both formats play through Quicktime anyway we can resue the code for playing mov files... The downside is that Quicktime doesn't offer you full screen viewing that we would get from JW viewer...

Show
Andy Kemp added a comment - As a quick temporary fix though you can add the following lines to relevant section in filter.php: if ($CFG->filter_mediaplugin_enable_mov) { $search = '/<a.*?href="([^<]+\.mp4)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); } if ($CFG->filter_mediaplugin_enable_mov) { $search = '/<a.*?href="([^<]+\.m4v)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); } As both formats play through Quicktime anyway we can resue the code for playing mov files... The downside is that Quicktime doesn't offer you full screen viewing that we would get from JW viewer...
Hide
Martin Dougiamas added a comment -

Unfortunately we can't include JW Player as it is, because their license is incompatible with the GPL. I'll seek permission for it.

In the meantime, I've added support for them via the Quicktime plugin.

Show
Martin Dougiamas added a comment - Unfortunately we can't include JW Player as it is, because their license is incompatible with the GPL. I'll seek permission for it. In the meantime, I've added support for them via the Quicktime plugin.
Hide
Andy Kemp added a comment -

Thanks Martin,
I wondered if this might be the case. I have therefore written a seperate MP4 filter which uses the JW Viewer which I'm currently hosting at:
http://www.andykemp.org.uk/2009/07/mp4s-in-moodle/

Show
Andy Kemp added a comment - Thanks Martin, I wondered if this might be the case. I have therefore written a seperate MP4 filter which uses the JW Viewer which I'm currently hosting at: http://www.andykemp.org.uk/2009/07/mp4s-in-moodle/
Hide
Ralf Krause added a comment -

Cool! Movies can be shown as mp4 in Moodle. m4v is still downloaded. I think that Quicktime can't show embedded m4v.

Show
Ralf Krause added a comment - Cool! Movies can be shown as mp4 in Moodle. m4v is still downloaded. I think that Quicktime can't show embedded m4v.
Hide
Ralf Krause added a comment -

Sorry, Quicktime and m4v are okay. Quicktime definitly plays m4v movies which are embedded in a web page.

Use the guest account and the key "test" to access to my examples.
http://moodle4mac.dyndns.org/moodle19/course/view.php?id=2

If I use a "Link to a file or web page" then the m4v file is downloaded and not shown in Moodle. (see topic 1)

If I use a link in a label then the mp4 movie is embedded. You can set the size. (see topic 2)
The embedded version works also with m4v videos (see topic 3)

Do you think that you will get the "Link to a file or web page" working?

Show
Ralf Krause added a comment - Sorry, Quicktime and m4v are okay. Quicktime definitly plays m4v movies which are embedded in a web page. Use the guest account and the key "test" to access to my examples. http://moodle4mac.dyndns.org/moodle19/course/view.php?id=2 If I use a "Link to a file or web page" then the m4v file is downloaded and not shown in Moodle. (see topic 1) If I use a link in a label then the mp4 movie is embedded. You can set the size. (see topic 2) The embedded version works also with m4v videos (see topic 3) Do you think that you will get the "Link to a file or web page" working?
Hide
Ralf Krause added a comment -

Please also add m4a for "Anhanced Audio"

In education and learning it could be important to add pictures and hyperlinks to an audio file. So the students can hear people talking in an interview and see some pictures and links matching to the informations.
http://en.wikipedia.org/wiki/M4a#.MP4_versus_.M4A_file_extensions

It's really easy to add the m4a support for the multimedia filter
if ($CFG->filter_mediaplugin_enable_mov) {
$search = '/<a.?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.*?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);
}

Please look at the example on my web site
http://moodle4mac.dyndns.org/moodle19/course/view.php?id=2&topic=0#section-4
Login as a guest with the key "test"

Show
Ralf Krause added a comment - Please also add m4a for "Anhanced Audio" In education and learning it could be important to add pictures and hyperlinks to an audio file. So the students can hear people talking in an interview and see some pictures and links matching to the informations. http://en.wikipedia.org/wiki/M4a#.MP4_versus_.M4A_file_extensions It's really easy to add the m4a support for the multimedia filter if ($CFG->filter_mediaplugin_enable_mov) { $search = '/<a.?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); } Please look at the example on my web site http://moodle4mac.dyndns.org/moodle19/course/view.php?id=2&topic=0#section-4 Login as a guest with the key "test"
Hide
Ralf Krause added a comment -

There is still a bug in the filter code ... m4v and m4a are working with Safari on Mac OS X but not with Firefox!

Looking at the code I found the string "type=document/unknown" in the object description. That's definitly wrong! If this string is "type=video/mp4" then the filter also would run with Firefox.

I had to add two lines into the function get_mimetypes_array() in the file moodle/lib/filelib.php
'm4v' => array ('type'=>'video/mp4', 'icon'=>'video.gif'),
'm4a' => array ('type'=>'video/mp4', 'icon'=>'video.gif'),

Remember the addition for m4a in the file moodle/filter/multimedia/filter.php
if ($CFG->filter_mediaplugin_enable_mov) {
$search = '/<a.?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.*?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);
}

Please add this all into the code to get the multimedia support for m4v and m4a.

Thanks, Ralf

Show
Ralf Krause added a comment - There is still a bug in the filter code ... m4v and m4a are working with Safari on Mac OS X but not with Firefox! Looking at the code I found the string "type=document/unknown" in the object description. That's definitly wrong! If this string is "type=video/mp4" then the filter also would run with Firefox. I had to add two lines into the function get_mimetypes_array() in the file moodle/lib/filelib.php 'm4v' => array ('type'=>'video/mp4', 'icon'=>'video.gif'), 'm4a' => array ('type'=>'video/mp4', 'icon'=>'video.gif'), Remember the addition for m4a in the file moodle/filter/multimedia/filter.php if ($CFG->filter_mediaplugin_enable_mov) { $search = '/<a.?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.*?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); } Please add this all into the code to get the multimedia support for m4v and m4a. Thanks, Ralf
Hide
Ralf Krause added a comment -

Sorry, but m4a is an audio file
'm4v' => array ('type'=>'video/mp4', 'icon'=>'video.gif'),
'm4a' => array ('type'=>'audio/mp4', 'icon'=>'audio.gif'),

I found the following mime types but I don't know if this would be better
'm4v' => array ('type'=>'video/x-m4v', 'icon'=>'video.gif'),
'm4a' => array ('type'=>'audio/mp4a-latm', 'icon'=>'audio.gif'),
See http://www.feedforall.com/mime-types.htm

Show
Ralf Krause added a comment - Sorry, but m4a is an audio file 'm4v' => array ('type'=>'video/mp4', 'icon'=>'video.gif'), 'm4a' => array ('type'=>'audio/mp4', 'icon'=>'audio.gif'), I found the following mime types but I don't know if this would be better 'm4v' => array ('type'=>'video/x-m4v', 'icon'=>'video.gif'), 'm4a' => array ('type'=>'audio/mp4a-latm', 'icon'=>'audio.gif'), See http://www.feedforall.com/mime-types.htm
Hide
Eloy Lafuente (stronk7) added a comment -

I've added support for m4a files and missing mimetypes as suggested by Ralf. Thanks!

Show
Eloy Lafuente (stronk7) added a comment - I've added support for m4a files and missing mimetypes as suggested by Ralf. Thanks!
Hide
Ralf Krause added a comment -

super!
thanks

Show
Ralf Krause added a comment - super! thanks
Hide
Bruce Webster added a comment -

Youtube videos can be fairly easily downloaded in mp4 format - though they don't give you the link, here is a 2-click solution for getting any video you're watching from youtube:
http://googlesystem.blogspot.com/2008/04/download-youtube-videos-as-mp4-files.html

I really like the fact that mp4 files play in Flash now, but only simple baseline ones (such as youtube's ones). Here's a flash mp4 filter, but it won't work with all mp4 files.

http://www.andykemp.org.uk/2009/07/mp4s-in-moodle

Show
Bruce Webster added a comment - Youtube videos can be fairly easily downloaded in mp4 format - though they don't give you the link, here is a 2-click solution for getting any video you're watching from youtube: http://googlesystem.blogspot.com/2008/04/download-youtube-videos-as-mp4-files.html I really like the fact that mp4 files play in Flash now, but only simple baseline ones (such as youtube's ones). Here's a flash mp4 filter, but it won't work with all mp4 files. http://www.andykemp.org.uk/2009/07/mp4s-in-moodle
Hide
Ralf Krause added a comment -

Yes, some mp4 files are playing with the filter and others not.
Also Martin wrote about the problem with the license for using the filter in Moodle for commercial purposes.

Show
Ralf Krause added a comment - Yes, some mp4 files are playing with the filter and others not. Also Martin wrote about the problem with the license for using the filter in Moodle for commercial purposes.
Hide
Thomas Bachert added a comment -

The filter support for mp4 and m4v did not load, although the new YouTube link filter did. Can somebody update the CVS head for 1.9.6 stable (MOODLE_19_STABLE)? I upgraded to 1.9.6+ Build 20091111.

Show
Thomas Bachert added a comment - The filter support for mp4 and m4v did not load, although the new YouTube link filter did. Can somebody update the CVS head for 1.9.6 stable (MOODLE_19_STABLE)? I upgraded to 1.9.6+ Build 20091111.
Hide
Ralf Krause added a comment -

Hi Thomas,

I got no problem to download Moodle 1.9.6+ (20091121) via CVS including the Multimedia filter.
cvs -z9 -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle co -P -r MOODLE_19_STABLE moodle

Best regards, Ralf

Show
Ralf Krause added a comment - Hi Thomas, I got no problem to download Moodle 1.9.6+ (20091121) via CVS including the Multimedia filter. cvs -z9 -d:pserver:anonymous@uk.cvs.moodle.org:/cvsroot/moodle co -P -r MOODLE_19_STABLE moodle Best regards, Ralf
Hide
Anil Sharma added a comment -

I've downloaded 1.9.7+ and I don't see support for .mp4 or m4v in the default filters page

Show
Anil Sharma added a comment - I've downloaded 1.9.7+ and I don't see support for .mp4 or m4v in the default filters page
Hide
Ralf Krause added a comment -

The filter settings for mp4, m4v, and m4a can't be seen in the dialog.
It would be helpful to add a notice for these media files.

Ralf

Show
Ralf Krause added a comment - The filter settings for mp4, m4v, and m4a can't be seen in the dialog. It would be helpful to add a notice for these media files. Ralf
Hide
Ralf Krause added a comment -

Hi Anil,

the media files mp4, m4v, and m4a are using thae same setting as .mov does.
If you will get a look at the source then you will see this in file moodle/filter/mediaplugin/filter.php

Best regards, Ralf

if ($CFG->filter_mediaplugin_enable_mov) {
$search = '/<a.*?href="([^<]+\.mov)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);

// MDL-18658
$search = '/<a.*?href="([^<]+\.mp4)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);

$search = '/<a.*?href="([^<]+\.m4v)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);

$search = '/<a.*?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is';
$newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext);
}

Show
Ralf Krause added a comment - Hi Anil, the media files mp4, m4v, and m4a are using thae same setting as .mov does. If you will get a look at the source then you will see this in file moodle/filter/mediaplugin/filter.php Best regards, Ralf if ($CFG->filter_mediaplugin_enable_mov) { $search = '/<a.*?href="([^<]+\.mov)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); // MDL-18658 $search = '/<a.*?href="([^<]+\.mp4)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); $search = '/<a.*?href="([^<]+\.m4v)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); $search = '/<a.*?href="([^<]+\.m4a)(?d=([\d]{1,4}%?)x([\d]{1,4}%?))?"[^>]>.?<\/a>/is'; $newtext = preg_replace_callback($search, 'mediaplugin_filter_qt_callback', $newtext); }

Dates

  • Created:
    Updated:
    Resolved: