Video and image processing on WebFaction servers

There’s a common misconception that you can’t use shared hosting for interesting tasks like image and video processing. But at WebFaction we say au contraire; today we’re taking a look at the image processing tools available on our servers.

For starters, let’s take ImageMagick for test drive. ImageMagick is a library and collection of command line tools for working with bitmap images. Here it is on web310:

$ convert -version
Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

ImageMagick has a broad range of capabilities, from resizing an image to creating animations. Here’s an example of converting the WebFaction logo from one type to another:

$ convert -quality 50 webfaction-logo.png webfaction-logo.jpg

ImageMagick is handy to have around, but if you’re working with Python, you might prefer to use PIL, the Python Imaging Library. Like ImageMagick, PIL provides a variety of ways to manipulate images. Here’s an example of resizing an image with PIL (on web310):

$ python2.7
Python 2.7.3 (default, May 18 2012, 14:51:16)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> im = Image.open("webfaction-logo.png")
>>> small = im.resize((130, 30))
>>> small.save("webfaction-logo-small.png")

Still images are nice, but it doesn’t hurt to add some motion and sound every now and then. FFmpeg provides a number of tools and libraries for working with video and audio. Here’s an example of converting a Quicktime video from a point-and-shoot camera to a web-friendly MP4:

$ ffmpeg -v 0 -i short_clip.mov short_clip.mp4
FFmpeg version UNKNOWN, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-libamr-nb --enable-libamr-wb --enable-   libfaac --enable-libfaad --enable-libmp3lame --enable-nonfree
  libavutil     49.14. 0 / 49.14. 0
  libavcodec    52.15. 0 / 52.15. 0
  libavformat   52.28. 0 / 52.28. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Sep 13 2011 08:22:01, gcc: 4.4.4 20100726 (Red Hat 4.4.4-13)
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=  224 fps= 50 q=31.0 Lsize=    1301kB time=7.38 bitrate=1443.7kbits/s
video:1239kB audio:57kB global headers:0kB muxing overhead 0.414617%

And, as we’ve mentioned previously, you can build other great image and video tools in your home directory. What are you doing with images and video? Let us know in the comments. If you have any questions, join us on the Q&A Community.

This entry was posted in General. Bookmark the permalink.

7 Responses to Video and image processing on WebFaction servers

  1. Iqbal Yusuf says:

    This is a great news. We use FFMPEG to transcode videos submitted to us by our users. Till now we have used our local machine to run FFMPEG. Having this capability in servers opens up a few ideas that we can implement. We can use PHP to automate transcoding job on the server now.

    My worry is that FFMPEG eats up resources a lot. What is the threshold limit that Webfaction management will tolerate when I run this FFMPEG on a shared host?

    Thanks,
    Iqbal

  2. Brian Ruff says:

    It’s great you guys are offering image and video process, but any possibility of offering audio processing in the near future. Any time I want to use LAME to encode audio I end up having to set up a VPS or server somewhere else outside of WebFaction.

  3. anrake says:

    So we don’t even need to install Imagemagick? If I want to use it through a Rails app just install the Rmagick gem? I was starting to look into this recently and thought I see a guide to installing Imagemagick and Rmagick for Rails in the support area.

  4. Remi D says:

    ImageMagick is already pre-installed. You can install the RMagic gem by following these simple steps: http://docs.webfaction.com/software/ruby.html#installing-gems

  5. Pete says:

    This is really great, and timely! I’m actually in the planning stages (need to actually take action and *do* this rather than just think about it…) of creating a Pyramid-based image and video gallery. I’m actually looking at integrating with Amazon S3 for the media storage and their new video transcoding service, but will be taking advantage of PIL for the local image processing.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>