FFMPEG And FlashVideo For Fedora (Or CentOS)

Interested in processing your own video on your Drupal website?

Photo of Greg Harvey
Thu, 2009-05-07 12:22By greg

Good news for all you people who want to process their own video on their Drupal website. While FFMpeg is a "forbidden" application as far as the Fedora project guys and gals are concerned (not sure why - usually because of some legal issue), the ATrpms repositories contain FFMpeg, the Linux command line video encoding tool you need to install to use the FlashVideo module:


Coincidentally, they keep RHEL repos too and I checked the RHEL 5 repository - it too contains FFMpeg, so RedHat and CentOS are covered:


There are some basic installation instructions for installing the ATrpms repository and FFMpeg here, which should work on Fedora, RHEL and CentOS - just make sure you use the correct repo:


Happy days! =)

(For the record, apparently RPM Fusions includes FFMpeg as well if you already use it or prefer it.)

Now we've got FFMpeg, but we're not quite out of the woods yet, because it doesn't support mp3 or mp4 encoding out of the box. To do this it relies on an encoder called 'mp3' which is part of the libavcodec1d package. Unfortunately for us, that package tends to ship with Debian-based distros (like Ubuntu) and no one seems to have ever made an RPM of it for Fedora. As such, the path of least resistance is to install a different encoder.

So instead you will need to install lame (also in the ATrpms repository) - the RHEL/RPM equivalent to the mp3/mp4 bits of libavcodec1d. I'm not sure, but I think it is installed automatically when you install FFMpeg, as it's already there for me and I don't recall installing it. You can do a test encode from the command line, something like this, assuming you have a "myvideo.mp4" file in your Documents directory:

ffmpeg -i ~/Documents/myvideo.mp4 -f flv -acodec libmp3lame -ar 22050 ~/Documents/myoutput.flv

You might see an error message about output buffers and audio conversion failing. Ignore it. It's not true - watch your FLV and you'll see it is fine. If it *really* doesn't work, you'll have to hit Google. But it should (or it did for me at any rate).

Ok, our Linux environment is ready. Time to install that FlashVideo module. Follow the instructions here - this is an excellent walk-through tutorial - until you get to "Create your Page!", then stop and come back to this blog post: http://www.travistidwell.com/flashvideo

So you've done most of Travis' tutorial... nearly there! Before you do the "Create your Page!" step you have one more thing to do to make things work in Fedora.

In your settings for your content type (yes, this is a content type level setting, not a general setting) you need to expand the "FFMPEG settings" field group and change the "ffmpeg Command" box to read: -i @input -f flv -acodec libmp3lame -ar 22050 -ab 64k -ac 1 @output

The -acodec libmp3lame bit is the key. We tell FlashVideo not to use the 'mp3' encoder, but to use the 'libmp3lame' encoder that comes with the lame package we installed earlier.

You should also make sure you enable "Log Conversion Data" while you're in there. It's very useful if things don't go according to plan and you need it while you debug things.

Now you're set to carry on with the other tutorial and try to upload a video. Hopefully all will go swimmingly, cron.php will take a minute to run and your video will successfully process. If not, see the ffmpeg_data table in your Drupal database for details of what FFMpeg thinks went wrong.

Assuming things *were* successful, you're ready to view your video. You've already chosen and downloaded a player, as instructed by Travis. If you want to show videos in your node template by default then go to the Help section in Drupal admin. You'll find good instructions documented there, specifically at: /admin/help/flashvideo#displaying2


You got FlashVideo and FFMpeg working on Fedora/CentOS/RHEL. =)

Finally, some footnotes and links:

Firstly, don't use the CCK feature yet - at time of writing, this does not work (FlashVideo 6.x-1.5-rc2) - use the Upload module instead. Create a content type and enable attachments, in the FlashVideo settings enable video on that content type, then add a new node and save. Run /cron.php and wait. If it takes several seconds/minutes to run, this is a good thing. If it's all over in a second, something went wrong - see the ffmpeg_data table in your Drupal database for details.

If you're having problems with FFMpeg or don't want to use it for some other reason, the RPM Fusion repository also includes an encoder called Sox.

Now looking at the config options for the FlashVideo module, I'm sure it's possible to make it use Sox instead of FFMpeg, but it's not something I've tried yet. If I do, I'll blog it. =) This is a pretty good general resource for FFMpeg: http://howto-pages.org/ffmpeg/

One other note. A competitor to FlashVideo that appears to be going well is this module, Blue Droplet Video: http://drupal.org/project/bd_video One to watch, I think.

Another possible alternative is Video. It has no upload facility yet, but supposedly it is pending. Quite why the developers opted to do it for Drupal 4.7 first is beyond me, but it's pretty old now and I guess upload isn't their primary objective. Anyways, project is here: http://drupal.org/project/video