Set up your own media-sharing site with MediaGoblin
The same way that "ease of use" usually equates to less flexibility, "convenience" is nearly always synonymous with less privacy, and YouTube nowadays is very, very convenient. If you just want to share a video, and not your personal data, or you want to avoid rude users from commenting on your kids' videos, MediaGoblin is what you need.
MediaGoblin  has several things going for it, not least of which is that, in this post-PRISM world, you can set up and control you own personal media-sharing site without having to go through Google or Vimeo. MediaGoblin is also very versatile, because it can also act as a stand-in for Flickr, SoundCloud, and soon Blogger. Additionally, it can render 3D files in real time.
As usual, I used a stock Debian Wheezy on VirtualBox with all updates applied on 28/09/2013 as my test machine. When installing Debian, I chose the server option (databases, web servers, etc.). MediaGoblin itself is still under heavy development and is not yet packaged into most distros.
Your best option is to grab the latest version from its Git repository, so first you'll need to get and install Git, then clone MediaGoblin and download all the necessary files:
# apt-get install git $ git clone git://gitorious.org/MediaGoblin/MediaGoblin.git
Because MediaGoblin is a rather complex piece of software, several dependencies need to be satisfied:
# apt-get install python python-devpython-lxml python-imaging python-virtualenv
Unless you plan to have a dedicated server running your site, the recommended approach is to run MediaGoblin in its own Python environment.
The next step is to set up the database back end. MediaGoblin supports both PostgreSQL and SQLite (the default), but the latter is not very scalable and only works for very small deployments. I'll go with the PostgreSQL deployment. To begin, install the PostgreSQL packages:
# apt-get install postgresql postgresql-client python-psycopg2 postgresql-server-dev
In Debian, PostgreSQL comes with a passwordless user called postgres, from which you can run PostgreSQL commands. You cannot access this user directly (e.g., with
su postgres), because no password will work, so you have to access
root and then move down into
$ su # su postgres
Once you're logged in as postgres, you can start building the framework for MediaGoblin. First, create a MediaGoblin user for the database
$ createuser MediaGoblin
and answer no to the three questions PostgreSQL asks you about the user's privileges.
Next, you can create the database proper:
$ createdb -E UNICODE -O MediaGoblin MediaGoblin
This step creates the database MediaGoblin and assigns ownership to the user MediaGoblin.
The MediaGoblin documentation recommends creating an unprivileged, passwordless Linux user account to run the server, so I'll show how to do that, too. To start, exit from the postgres user to root:
Next, create the Linux user using the
--group flags as follows:
# adduser --shell /bin/bash --no-create-home --system--group MediaGoblin
Copy the directory with the MediaGoblin files to your web server root directory
# cp -Rv MediaGoblin/ /var/www/
and change ownership to the MediaGoblin user:
# chown -hR MediaGoblin:MediaGoblin /var/www/MediaGoblin/
You can now
su into the MediaGoblin account and
cd into the
MediaGoblin server directory to continue with the installation:
# su MediaGoblin $ cd /var/www/MediaGoblin
I will assume that all the following steps are executed from within the /var/www/MediaGoblin directory.
Unless you are dedicating a whole machine to MediaGoblin, you are advised to run all its programs from within a Python virtual environment. You can set up the environment with
$ (virtualenv --system-site-packages . ||virtualenv .)&& ./bin/python setup.py develop
MediaGoblin requires FastCGI and needs flup (a "Random assortment of WSGI servers," according to the project page). You can install flup with
$ bin/easy_install flup
The final step is to create and modify the
MediaGoblin_local.ini file: Copy
MediaGoblin_local.ini, open the newly created file with a text editor, and uncomment the line
# sql_engine = postgresql:///MediaGoblin
Next, change the fake email address in the line
email_sender_address = "notice@MediaGoblin.example.org"
to an address from which you want warnings sent. You'll also need to edit
MediaGoblin/config_spec.ini, specifically the lines shown in Listing 1, to configure the setup for your email server.
email_debug_mode = boolean(default=True) email_smtp_use_ssl = boolean(default=False) email_sender_address = string(default="firstname.lastname@example.org") email_smtp_host = string(default='') email_smtp_port = integer(default=0) email_smtp_user = string(default=None) email_smtp_pass = string(default=None)
When you're done, you can save all the files and run:
$ bin/gmg dbupdate
By the way,
gmg is a MediaGoblin tool that comes with several utilities for updating databases and managing users; it even provides a Python shell to monitor and change MediaGoblin's behavior on the fly. In this case, I'll update the databases in MediaGoblin.
With that, installation is complete. You can test your site by running
$ ./lazyserver.sh --server-name=broadcast
and visiting http://localhost:6543 (Figure 1).
By using the
--server-name=broadcast option, you should also be able to access the server on your intranet at http://serverip:6453.
Although MediaGoblin comes with its own server embedded for testing purposes, this server is not adequate for production. To help serve all the static material, you should deploy MediaGoblin with a full-fledged web server, such as Apache or Nginx .
The MediaGoblin documentation project provides plenty of examples of scripts to optimize the execution of Celery (an asynchronous task queue that allows users to load media while visiting other parts of your site) and FastCGI (a framework that provides a way to improve the performance of server-side scripts) for various web servers. It also provides startup scripts for Linux so that the server runs every time the machine is powered up.
Apart from that, most administration of the site itself is done by editing the
MediaGoblin_local.ini and the
paste_local.ini files created earlier. One of the first things you must do is change the line
email_debug_mode = true
email_debug_mode = false
so that the system sends email to users (e.g., verification email). If you don't, the text of the email will show up on the
lazyserver output, but won't be sent over the Internet. As mentioned previously, you will also have to write in the correct configuration for your email service in
Another thing you can do is turn off registration if you just want to set up a private website. You can do that by changing the line
allow_registration = true
allow_registration = false
allow_registration set to
false, only the server administrator can create user accounts, which can be done with
$ bin/gmg adduser
The script will prompt you for a username and password and register the user with your instance of MediaGoblin.
To make a user a site administrator, you also use
$ bin/gmg makeadmin <username>
Currently, the site admin's powers are limited to being able to monitor contents being processed.
Finally, there's the matter of getting types of media working on your server.
By default, your MediaGoblin site will allow you to upload images. Try anything else, and you'll get the message, Sorry, I don't support that file type :( (Figure 2).
If you look under
MediaGoblin/media_types/, however, you will also see the
video/ directories. These contain the plugins for the different types of media. The
MediaGoblin/media_types/audio directory, for example, contains the configuration files and all the code necessary to allow MediaGoblin to understand OGG, MP3, and WAV files.
To add audio to your setup, open your
MediaGoblin_local.ini file in a text editor and add
Note, however, that you're not done yet. If you run
gmg updatedb (which is what you have to do every time you update
MediaGoblin_local.ini), it will choke on half a dozen failed dependencies. You have to install a bunch of XML and sound-related packages on your system,
# apt-get install libxml2-dev libxslt-dev python-gst0.10-devlibsndfile1-dev
along with several Python packages in your virtual environment,
$ bin/easy_install jinja2 $ bin/easy_install Pygments $ bin/easy_install lxml $ bin/easy_install psycopg2 $ bin/easy_install scikits.audiolab
before things start to look good.
Now you can run
gmg updatedb and the command
$ ./lazyserver.sh --server-name=broadcast
to start uploading audio files to MediaGoblin. The system even renders a graphic wave representation of your files (Figure 3).
The great thing is that, if you get audio files working on your site, you won't have to do much else if you want to upload videos (Figure 4). Just add the line
[plugins] section of
gmg updatedb and
lazyserver.sh again, and video support will be implemented into your setup.
MediaGoblin transforms all videos to the WebM format, the open video format developed by Google, and, in theory, supports a wide variety of upload formats. I tried MP4 and WebM, which worked fine, as well as OGV (Ogg Theora), which didn't. There's a bug in the thumbnail-creating code of the version I was using (nightly 0.6.0). I hope by the time you read this, that bug will have been squashed.
Buy this article as PDF
Innovative system adds a hard drive and Ubuntu Core to the RPi for an IoT hub.
Linux is two weeks younger than we thought!
The Apache Software Foundation considers retiring OpenOffice
Adobe won’t kill the plugin in 2017
Linux Foundation's big event celebrates the 25th anniversary of Linux
Competitors get in the game with RHEL without Red Hat
Security researchers have already notified Microsoft; some fixes are available
The company is collaborating with Google and Intel to use Kubernetes as an engine for Fuel