Birdfeed
ffmpeg, the flashvideo module and testing locally on Windows
We like using the FlashVideo module in some of our Drupal installations, as being able to transcode submitted videos via ffmpeg is pretty sweet. However, as you may know — testing this locally on Windows can be a difficult task, as setting up ffmpeg locally can be somewhat enigmatic to say the least. Right now I’ve only tested this method on XP (I ‘m stubborn and haven’t, erm, “upgraded ” to Vista yet), so anyone who can confirm it works on Vista — please! I don’t see why it wouldn’t, though, as it’s really just an executable file. [Works for me on Vista! -Ed.]
Just FYI — I’m running Apache (using the great XAMPP distribution) locally for testing purposes. I don’t think this matters too much, but wanted to throw it in there.
I’ve opted to not cover how to install and configure FlashVideo, as there is good documentation available for that here. This tutorial is focused on installing ffmpeg locally, so you can test workflow, etc on your machine before you go to staging on a live server (which ideally will already be configured with ffmpeg).
First of all, you need to find windows binaries for ffmpeg. The one I’m using came from http://ffdshow.faireal.net/mirror/ffmpeg/. I just downloaded the most recent archive in the list.
Decompress the archive somewhere inside your Drupal installation folder. I make sure to exclude it when on commit to a live server, cause its pretty useless once you go live on a linux box or what-have-you. I guess being lazy and leaving it in wont hurt anything, but its sloppy!
Assuming you already have the FlashVideo module installed, lets work on the global FlashVideo settings first: admin/settings/flashvideo/edit/global
First things first, check the box to “Convert videos immediately”. I don’t really know why you’d ever not want to do this, but I guess there’s a case. If you don’t want to check this box, just make sure you run cron after you submit a node w/ a FlashVideo, to see if it worked.
Now, obviously there are a plethora of other options to choose from, all which are covered in the docs, so follow those to do whatever it is you’re doing, and we’re going to jump directly to the ffmpeg settings.
Scroll down and open the FFMPEG settings group. The first thing you’ll see is the ffmpeg command. The one that is set by default doesn’t exactly work properly (or didn’t for me), so I recommend starting with what I’m using:
-i @input -f flv -acodec libmp3lame -ar 22050 -ab 64k -ac 1 @output
as far as I remember, the thumbnail command was good to go, but just in case, here’s mine:
-y -i @input -vframes 1 -ss @thumbtime -an -vcodec mjpeg -f rawvideo -s "@thumbsize" @output
Next, you should enter the path to your ffmpeg executable. I extracted it to a folder off my installation called ffmpeg, so mine looks like this:
ffmpeg\ffmpeg.exe
Then I set up the output folders. I prefer to set the paths relative to the Drupal root (so I dont have to change this later), so mine are just set to files/original and files/converted, respectively.
Hit save configuration and go back to the main FlashVideo admin page: admin/settings/flashvideo.
Enable FlashVideo for whatever content types you want, tweak all your other settings and try adding a node with a video. On submit, the files should convert and end up in the folders you specified.
Doesn’t work? Double check your path to ffmpeg and your conversion commands. Make sure your new node has the [video] tag somewhere in the body. If everything seems in order, there’s one last way to troubleshoot.
Go back to your global settings and tick the box for “Log Conversion Data” and save your settings.
Open up phpmyadmin (or whatever you feel like using to browse your mysql db) and look for the table ffmpeg_data. Browse the table and you should see a row for every time you submitted a content type that tried to run a conversion.
Choose a row and look at the fields. input_file and output_file should show the filename of what you’re trying to convert including path (relative to the Drupal root).
Now drop down to a command prompt and change to the directory you decompressed ffmpeg to. Try running ffmpeg with the command you specified in the configuration, with the input and output files replaced with what you found in the db (make sure you adjust the path to be accurate, Drupal runs ffmpeg from it’s root). A test case for me looked like this:
C:\drupal_site\ffmpeg>ffmpeg -i ../files/original/Test.mov -f flv -acodec libmp3lame -ar 22050 -ab 64k -ac 1 ../files/converted/Test.flv
If anything goes wrong, you should see an error message. If this is the case, sorry I couldn’t help. At least now you’ll have something to stick into Google.
Now, worth mentioning is that when you go live you must remember to change the ffmpeg path to wherever the binary resides on your server. You can ask your admin where it is if you dont know, but for my server, I change the path to /usr/local/bin/ffmpeg.
This posting doesn’t really cover you if you’re looking to set up ffmpeg-php, however Lorenzo Gangi already has you covered on this one, and it works for me.
Submitted by canary on Sat, 05/31/2008 - 2:42am