FFmpeg
From DreamHost
| The instructions provided in this article or section are considered advanced. You are expected to be knowledgeable in the UNIX shell. Server changes may cause this to break. Be prepared to troubleshoot this yourself if this happens. |
FFmpeg is a program that can record, convert and stream digital audio and video in numerous formats. Its most widely used to convert video files to the popular FLV format for playback using a Flash video player in a web browser. On Dreamhost, it can be used with Gallery to create movie thumbnails.
Contents |
Shared Installation
By default, Dreamhost users have access to a shared installation of FFmpeg.
In web applications, such as Gallery, the absolute path to the shared installation of FFmpeg is:/usr/bin/ffmpegThe absolute path to the supporting libraries is:
/usr/lib/vhook
Manual Install of FFmpeg
If you'd like to download, compile, and install a more recent version of FFmpeg, follow these instructions carefully.
- Make sure you are using a username that shell access to your account. Using an SSH client (such as PuTTY), open a session with the machine that hosts your website. EXAMPLE: flamenco.dreamhost.com Log in using your username and password. When logged in, you will be automatically placed in your home directory.
- To see a list of files and directories in your home directory, type:
dir
- If the bin directory doesn't already exist, create it by typing:
mkdir bin
- Set the correct permissions for the bin directory by typing:
chmod 775 bin
- If the lib directory doesn't already exist, create it by typing:
mkdir lib
- Set the correct permissions for the lib directory by typing:
chmod 775 lib
- If the tmp directory doesn't already exist, create it by typing:
mkdir tmp
- Set the correct permissions for the tmp directory by typing:
chmod 775 tmp
- Type:export TMPDIR=/home/username/tmpwhere username is the same username you used to log into the SSH session
- Download the latest version of FFmpeg into a new temporary directory called ffmpeg by typing:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
- Navigate to this new directory by typing:
cd ffmpeg
- Now, configure some options by typing:
./configure --prefix=$HOME --enable-cross-compile --enable-shared
- Next, compile the FFmpeg program by typing:
make
- Install FFmpeg by typing:
make install
- Return to your home directory by typing:
cd ..
- Remove the temporary ffmpeg directory by typing:
rm -rf ffmpeg
If no errors occur, FFmpeg should now be installed.
Configuring Web Applications
In web applications, such as Gallery, the absolute path to your manual installation of FFmpeg is:The absolute path to the supporting libraries is:/home/username/bin/ffmpegwhere username is the same username you used to log into the SSH session.
/home/username/lib/vhookwhere username is the same username you used to log into the SSH session.
Php Script For Converting Videos
for a php script, see the wiki article on php-ffmpeg here: php-ffmpeg
External Links
- Original source of this information
- FFmpeg web site
- Gallery web site
- WinFF A free cross-platform ffmpeg GUI for those of you who want to convert videos locally
- Downloadable pre-compiled version (created specifically for Dreamhost users by a Dreamhost user)
- Great support thread for configuring the pre-compiled ffmpeg binary (specifically the post by teequillin on June 6, 2006)
The last two links above got ffmpeg up and and running on a one-click Gallery install in 10 minutes (with no shell access required). Great way to go for those who are uneasy/unfamiliar with SSH.
FFMPEG for Automatic FLV creation
ffmpeg can be used to convert many video files from one format to another. I recently implemented this on a dreamhost server: http://openvlog.mobvcasting.com
Essentially you need the LAME and AMR libraries installed before installing FFMPEG. There are a couple of tricks to compiling FFMPEG following that which involve using switches for extra LD library and extra cflag paths:
./configure --prefix=/path/to/install --enable-mp3lame --extra-cflags=-I/path/to/lame/include --extra-ldflags=-L/path/to/lame/lib --enable-amr_nb --enable-amr_nb-fixed --enable-amr_if2 --enable-amr_wb
Then you need to update your LD_LIBRARY_PATH environment variable to include the new paths and use FFMPEG correctly.
Here is the command I use to generate FLVs:
/path/to/ffmpeg -i /path/to/inputfile.avi -acodec mp3 -ab 32 -ac 1 -ar 44100 /path/to/outputfile.flv
Cat put together this blog entry concerning the above.
Use the following commands on the shell from within the ffmpeg directory. This will download and correctly install the needed AMR libraries from http://www.3gpp.org/ You will need to do all three of the following.
# for --enable-amr mkdir -p libavcodec/amr_float wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip unzip 26104-510.zip unzip 26104-510_ANSI_C_source_code.zip -d libavcodec/amr_float
# for --enable-amr_nb-fixed mkdir -p libavcodec/amr wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip unzip 26073-510.zip unzip 26073-510_ANSI-C_source_code.zip -d libavcodec/amr
# for --enable-amr_wb --enable-amr_if2 mkdir -p libavcodec/amrwb_float wget http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip unzip 26204-510.zip unzip 26204-510_ANSI-C_source_code.zip -d libavcodec/amrwb_float

