FFmpeg

From DreamHost

Jump to: navigation, search
The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.
Support for these instructions is not available from DreamHost tech support.

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/ffmpeg
The 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.

  1. 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.
  2. To see a list of files and directories in your home directory, type:
    dir
  3. If the bin directory doesn't already exist, create it by typing:
    mkdir bin
  4. Set the correct permissions for the bin directory by typing:
    chmod 775 bin
  5. If the lib directory doesn't already exist, create it by typing:
    mkdir lib
  6. Set the correct permissions for the lib directory by typing:
    chmod 775 lib
  7. If the tmp directory doesn't already exist, create it by typing:
    mkdir tmp
  8. Set the correct permissions for the tmp directory by typing:
    chmod 775 tmp
  9. Type:
    export TMPDIR=/home/username/tmp
    where username is the same username you used to log into the SSH session
  10. Download the latest version of FFmpeg into a new temporary directory called ffmpeg by typing:
    svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
  11. Navigate to this new directory by typing:
    cd ffmpeg
  12. Now, configure some options by typing:
    ./configure --prefix=$HOME --enable-cross-compile --enable-shared
  13. Next, compile the FFmpeg program by typing:
    make
  14. Install FFmpeg by typing:
    make install
  15. Return to your home directory by typing:
    cd ..
  16. 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:
/home/username/bin/ffmpeg
where username is the same username you used to log into the SSH session.
The absolute path to the supporting libraries is:
/home/username/lib/vhook
where 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

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
Personal tools