Smart media aims to enhance Moodle's processing and delivery of multimedia while simplifying the process of managing multimedia for teachers and students.
The smart media plugins in Moodle aim to solve the following two user stories:
As a teacher I have a video that works on my local device and I want to make that video available to my students in a suitable format, by adding it to any rich text area in Moodle. Without the need for me to do any other operations on the video apart from uploading to Moodle.
As a student I want to be able to view any video on my chosen device; added to a rich text area in Moodle by a teacher. Regardless of the environment I’m accessing the video or my bandwidth limitations.
Smart media leverages cloud services provided through Amazon Web Services (AWS) in order to conduct video transcoding into required formats and provide additional analytics functionality for multimedia.
The following sections outline how to install the required smart media plugins in Moodle. For advanced setup and plugin usage once the plugins have been installed please see the project wiki.
This plugin currently supports Moodle:
- 3.9
Note: The high version of Moodle required is due to internal Moodle API's that this plugin depends on where only introduced in Moodle 3.9. If you want to use smart media in earlier Moodle versions please contact Catalyst IT for commercial support.
There are several dependencies required and steps to complete in order to setup smart media in your Moodle instance.
Note: These instructions assume knowledge of Git, Moodle plugin functionality and that you have access to the infrastructure that runs your Moodle instance.
- Install dependency plugin local_aws. See local_aws
- Clone the local_smartmedia plugin git repo into your Moodle codebase root
git clone [email protected]:catalyst/moodle-local_smartmedia.git local/smartmedia
- Install dependency plugin filter_smartmedia. See filter_smartmedia
- Install dependency binary FFmpeg on your Moodle server. See FFmpeg
- Setup the AWS Stack. See AWS Stack Setup
- Update plugin settings. See Plugin Settings
The local_aws plugin is a dependency for local_smartmedia, it provides the AWS PHP SDK that is required in order for Moodle to utilise AWS cloud services.
You can download this from the Moodle plugin library at https://moodle.org/plugins/local_aws
You can install this by cloning the git repo into your Moodle codebase:
git clone https://github.com/catalyst/moodle-local_aws local/aws
More detailed information is available at https://github.com/catalyst/moodle-local_aws in the README
The filter_smartmedia plugin is a dependency for local_smartmedia, it provides rendering of converted smart media assets in the Moodle UI.
You can install this by cloning the git repo into your Moodle codebase:
git clone https://github.com/catalyst/moodle-filter_smartmedia filter/smartmedia
More detailed information is available at https://github.com/catalyst/moodle-filter_smartmedia in the README
FFmpeg is an open source multimedia framework and provides the multimedia stream analyser ffprobe
, facilitating the collection of metadata for multimedia.
This metadata is utilised to identify which files in your Moodle instance to convert and to present reports on what media is actually in your Moodle instance.
FFmpeg is a requirement for running the local/smartmedia scheduled tasks.
To install FFmpeg, if your using a Debian based Linux distribution:
sudo apt-get update
sudo apt install ffmpeg
For Windows based or any other servers follow the instructions and link at https://ffmpeg.org/download.html
You can get more info about FFmpeg at https://ffmpeg.org/
The following steps will setup the Amazon Web Services (AWS) infrastructure. The AWS infrastructure is required to do the actual processing of multimedia files. While setting up the AWS infrastructure is largely automated by scripts included in this plugin, a working knowledge of AWS is highly recommended.
For more information on how the submitted files are processed in AWS please refer to the topic: Conversion Architecture
Note: Full support on setting up an AWS account and API access keys for AWS stack infrastructure provisioning is beyond the scope of this guide.
Note: This plugin currently does not support multiple Moodle's sharing Smartmedia Infrastructure. The AWS stack setup must be performed on an environment by environment basis, with a unique stack per environment.
To setup the AWS conversion stack infrastructure:
- Create an AWS account, see:
https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/
for information on how to do this. - Create an AWS API user with administrator access and generate a API Key ID and a API Secret Key, see:
https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html
for information on how to do this. - Change to your Moodle instance application directory. e.g.
cd /var/www/moodle
- Run the provisioning script below, replacing
<keyid>
and<secretkey>
With the AWS API Key ID and AWS API Secret Key that you obtained in step 2.
Replace<region>
with the AWS region you wish to set up your AWS stack, e.g.ap-southeast-2
.
The command to execute is:
sudo -u www-data php local/smartmedia/cli/provision.php \
--keyid=<keyid> \
--secret=<secretkey> \
--region=<region> \
Note: the user may be different to www-data on your system.
The script will return output similar to, the following:
== Creating resource S3 Bucket ==
Created resource bucket, at location http://smr1565939869-resource.s3.amazonaws.com/
== Uploading Lambda function archives to resource S3 bucket ==
Lambda archive uploaded sucessfully to: https://smr1565939869-resource.s3.ap-southeast-2.amazonaws.com/lambda_ai_trigger.zip
Lambda archive uploaded sucessfully to: https://smr1565939869-resource.s3.ap-southeast-2.amazonaws.com/lambda_rekognition_complete.zip
Lambda archive uploaded sucessfully to: https://smr1565939869-resource.s3.ap-southeast-2.amazonaws.com/lambda_resource_transcoder.zip
Lambda archive uploaded sucessfully to: https://smr1565939869-resource.s3.ap-southeast-2.amazonaws.com/lambda_transcoder_trigger.zip
Lambda archive uploaded sucessfully to: https://smr1565939869-resource.s3.ap-southeast-2.amazonaws.com/lambda_transcribe_complete.zip
== Provisioning the Lambda function to provide a custom cloudformation resource provider ==
Stack status: CREATE_IN_PROGRESS
Stack status: CREATE_COMPLETE
Cloudformation custom resource stack created. Stack ID is: arn:aws:cloudformation:ap-southeast-2:693620471840:stack/smr1565939869/f5f297c0-bff5-11e9-86c0-0290a6e588aa
Lambda Resource ARN: arn:aws:lambda:ap-southeast-2:693620471840:function:smr1565939869_transcoder_resource
== Provisioning the smart media stack resources ==
Stack status: CREATE_IN_PROGRESS
Stack status: CREATE_COMPLETE
Cloudformation stack created. Stack ID is: arn:aws:cloudformation:ap-southeast-2:693620471840:stack/smt1565939869/1a1e1570-bff6-11e9-b220-02a73bda2f36
Updating Lambda transcode funciton enivronment variables.
Environment variables updated
Updating Lambda transcode funciton enivronment variables.
Environment variables updated
== Provisioning the smart media stack resources ==
Smart media S3 user access key: AKIA2C8YAPAQEWV347IT
Smart media S3 user secret key: uBdLPiBwHj+ANmYP+bpzNx5zCEqjpktjFON/NsAG
Input bucket: smt1565939869-input
Output bucket: smt1565939869-output
Record the ouput from the resources section of the script information.
Once the dependency plugins are installed, the local/smartmedia plugin is installed, ffmpeg is installed and the AWS stack has been setup; it is now time to configure Moodle.
To do this:
- Log into the Moodle UI as a site administrator
- Navigate to
Site Administration > Plugins > Local plugins > Smart Media
. - Set all required fields. All of these with the exception of the FFProbe path will be gained from the output of the AWS stack provision script.
- All other settings can be left as their defaults
- Click
save changes
. - Navigate to
Site Administration > Plugins > Filters > Manage Filters
. - Enable the
Smart media
filter - Move the
Smart media
filter to be higher in priority (before) theMultimedia
fitler in the list of filters.
The following sections outline testing of the Smartmedia plugin from the CLI. Testing from the CLI is a good debugging technique, that verifies that the AWS architecture is setup correctly. It does not depend on Moodle or the configured plugin settings.
Once the AWS architecture has been setup using the provisioning script, it can be tested from the command line.
The following test command runs a basic conversion in AWS and returns the result status. To run the script:
- Change to your Moodle instance application directory. e.g.
cd /var/www/moodle
- Run the following command, replacing
<keyid>
and<secretkey>
With the AWS API Key ID and AWS API Secret Key that you obtained in the AWS Stack Setup.
Replace<region>
with the AWS region from the AWS stack set, e.g.ap-southeast-2
.
Replace<inputbucket>
and<outputbucket>
with the buckets from the setup.
Finally enter the path to the file wish to process.:
sudo -u www-data php local/smartmedia/cli/test.php \
--keyid=<keyid> \
--secret=<secretkey> \
--region=<region> \
--input-bucket=<inputbucket> \
--output-bucket=<outputbucket> \
--file='/var/www/moodle/local/smartmedia/tests/fixtures/SampleVideo1mb.mp4'
Note: the user may be different to www-data on your system.
The following sections provide an overview of some additional topics for this plugin and it's associated AWS architecture.
For advanced setup and plugin usage once the plugins have been installed please see the project wiki.
The below image shows the high level architecture the plugin provisioning process sets up in AWS.
2019 Catalyst IT Australia
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
This plugin was developed by Catalyst IT Australia: