Building a Video Library with FFMPEG

The video above is imported from http://www.centerforclinicalexcellence.com, for whom I’ve recently constructed a Buddypress Video Library using FFMPEG and the JW Player.

The owners of the site had originally wanted to use a third party like Vimeo or Twistage for this solution, but I persuaded them that they’d achieve a lot more flexibility and functionality if they went with a bespoke solution.

This would allow them to integrate seamlessly with their Buddypress User Database, which was not something that was going to happen very easily with a third party API.

I’m pretty happy with the finished product. Users can upload video, rate videos, comment on videos, embed videos in other sites, and linkback to videos through Facebook and Twitter.

FFMPEG isn’t for the faint hearted, however. It generally doesn’t come installed on hosting platforms, and has a long list of dependencies about which it is very particular when installing.

Normally, you can overcome this by installing through a package manager like yum on CentOS, which I have used before, but the current version of FFMPEG uses a version of libmp3lame (3.98.2, which is used for encoding audio) that contains a nasty little bug that prevents the duration of a clip being embeded in Flash encoded videos.

This in turn plays havoc with Flash players, who don’t know who long the video they are playing will run.

Unfortunately, there is no easy way in yum to specify the version of dependencies you want to use, so you have to go through all of FFMPEG’s dependencies and install them manually, just so you can install a downgraded version of libmp3lame (3.97) which doesn’t contain the bug.

You then need to comile FFMPEG from source.

This is a tricky process, but thankfully I found this article which gives a pretty good summary of what you have to do (there are one or two typos in it, but you’ll catch them as you proceed; and install lame 3.97, not 3.982 as listed). You also need to pay close attention re. the linking of libraries as described, and be sure to run ldconfig.

You can also leave 1 or 2 of the slightly less common codecs if they are giving your errors. The ones you really need are lame, faad, faac and vorbis.

JW Player by comparison is a breeze to install. The license and FB and Twitter plugins were purchased for the very reasonable sum of €77. Its a great player, and I’d recommend it to anyone.

One thought on “Building a Video Library with FFMPEG

Leave a Reply

Your email address will not be published.

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>