Anonymous media sharing with MediaCrush
Up to Speed
Sharing videos or images doesn't always require a full-fledged YouTube or Flickr clone. Sometimes all you want is a quick place to upload, so you can link to your media or share it online. MediaCrush gives you just that, as well as other interesting perks.
MediaCrush [1] is not a Flickr, YouTube, or SoundCloud stand-in, nor is it meant to be. If that's what you need, check out MediaGoblin, which I talked about in a previous article [2]. MediaCrush works more like Imgur [3], which allows you to upload images quickly and easily – with no registration required (Figure 1).
Like Imgur, MediaCrush (Figure 2) does not require registration, and it is absurdly simple to upload images to the site. The main aim of the site is to provide links or code snippets for embedding your media elsewhere. It was originally developed specifically for Reddit and is 100% RES (Reddit Enhanced Suite) compatible [4].
Even better, MediaCrush is completely open source, distributed under a permissive MIT license. Apart from bitmap images, it allows for vector SVG graphics, video, and audio, and it uses all the tricks in the book to compress your files so your site loads faster for visitors.
For example, when you upload a GIF animation, MediaCrush converts it into a losslessly compressed video (OGV or WEBM) and then shows the video on your site. A 998KB GIF I tried was compressed down to a 295KB OGV video – a 338% improvement (Figure 3). This has the added advantage of allowing users to pause the animation at any point. If you download the file, MediaCrush serves the original GIF image.
Get Ready
MediaCrush comes with a very comprehensive README.md
file with instructions on how to install the software. Unfortunately, not everything works as described.
As my test machine, I used a stock Debian Wheezy on VirtualBox with all updates applied as of November 26, 2013. When installing Debian, I chose the server option (databases, web servers, etc.).
The first thing you want to do is to get rid of Apache, so it doesn't hog port 80.
/etc/init.d/apache2 stop apt-get purge apache2
Next, make sure your repos are up to date with no obsolete software hanging around:
apt-get update apt-get upgrade
Because you'll need it to get the MediaCrush source, you have to install Git. While you're at it, you might want to grab Vim, too, which is useful for editing all the config files later.
apt-get install vim git
The MediaCrush developers also recommend compiling and installing the latest version of ffmpeg
to manage and convert video files. Before that works, you'll have to install more packages from your repositories:
apt-get install nasm libtheora-dev libvpx-dev ↩ libx264-dev libvorbis-dev pkg-config
Now, you can install FFmpeg, as shown by the command lines in Listing 1.
Listing 1
Installing FFmpeg
Next, you'll want to install the MediaCrush-specific dependencies:
apt-get install redis-server jhead tidy optipng
and Python-specific dependencies:
apt-get install python-dev libpcre3-dev python-virtualenv
Your system is now ready to install MediaCrush.
Getting the Code
To store the source code you're going to get from GitHub, create a directory,
mkdir mediacrush
and then get the source:
git clone http://github.com/MediaCrush/MediaCrush </route/to/your/>mediacrush
The download shouldn't take long. Once it's finished, create a virtual environment for MediaCrush:
virtualenv </route/to/your/>mediacrush --no-site-packages
This command ensures that MediaCrush uses only the modules it needs and that it also does not interfere with the rest of the system. To activate the environment, go into your folder and enter:
$ cd </route/to/your/>mediacrush $ source bin/activate
Now you have to install the Python modules that MediaCrush needs. The requirements.txt
file contains a list of all modules Python requires. Using pip
,
$ pip install -r requirements.txt
you can install everything in one go.
Get Going
Before running the server, you need to do several things. First, you have to create a storage
directory that will store the uploaded files under your MediaCrush directory, such as:
$ mkdir storage
Second, you have to rename the config.ini.sample
file to config.ini
and configure it. One of the changes you'll have to make in this file is at the storage_folder
line. For everything to work smoothly, you have to change
storage_folder = storage
to the absolute path to your storage directory:
storage_folder = </route/to/your/>mediacrush/storage
Additionally, you have to change the protocol
and domain
key-value pairs. Although the official MediaCrush site uses the HTTPS protocol to encrypt traffic to and from the site, for the sake simplicity, change the protocol
value to http
. For domain
, you enter the domain part of your site; for example:
domain = mymediacrush.net
To suit your setup, you may make many other changes in config.ini
. For example, you can integrate your Google AdSense and Analytics accounts, include the email of an administrator for abuse reports, or change the location of directories and files.
Finally, you have to run the MediaCrush daemon that does all the conversion in the back end:
$ python daemon.py&
The &
at the end pushes the execution of the daemon to the background, allowing you to run the server up front in the same terminal. If you enter
$ python app.py
MediaCrush runs in debug mode on port 5000. If you point your browser to the IP address of your server (e.g., http://192.168.1.110:5000), you should see a spanking new MediaCrush install waiting for your pics.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.