From DreamHost
Jump to: navigation, search


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.

Shared installation

By default, Dreamhost users have access to a shared installation of FFmpeg in the following directory:

DreamHost does not directly support any of the features described on this page and is not responsible for keeping this content updated or accurate. Use at your own risk!
There may be additional information on the talk page.

Installing libx264 on Private Servers using your ffmpeg installation

In order to compile your ffmpeg with the libx264 enabled, you have to use the following parameter:


This requires the lib264 installed on your system. The instructions to compile your own libx264 are described below.

First, you need to download the libx264 source. It's available to download via GIT. You can use the following commands:

  1. Move to home folder:
    cd ~
  2. Create the folder for source files:
    mkdir libx264-source
  3. Move to source files folder:
    cd libx264-source
  4. Download files via git:
    git clone git://git.videolan.org/x264.git

These commands will download the libx264 source files to /home/<USERNAME>/libx264-source folder.

In order to compile and install your libx264 to your home folder (/home/<USERNAME>), follow these steps:

  1. Move to source folder:
    cd libx264-source
  2. Move to x264 folder:
    cd x264
  3. Configure application (remember to replace <USERNAME> with your SSH login name)
    ./configure --enable-shared --disable-asm --prefix=/home/<USERNAME>
  4. Compile:
  5. Install:
    make install

Note: you don't need to use --prefix as /home/<USERNAME>/bin because libx264 will create if it doesn't exist, and will also create a /lib and /include folders inside your home directory to keep other necessary files, including the x264.h header file. You can check if libx264 was installed successfully by running the following commands:

  1. Make sure we're in home folder:
    cd ~
  2. Move to bin folder:
    cd bin
  3. Ask x264 to help us!
    ./x264 --help

This should display the libx264 help text.

Now that we have the libx264 installed, we can compile ffmpeg using it. Problem is: by default, ffmpeg will look for the header files (the x264.h file mentioned above) in the /usr/lib folder. So you will have to run this following command when configuring your ffmpeg installation instead:

./configure --prefix=/home/<USERNAME> --enable-cross-compile --enable-shared --arch=amd64 --target-os=linux --enable-libx264 --disable-yasm --extra-cflags=-I/home/<USERNAME>/include --extra-ldflags=-L/home/<USERNAME>/lib

This will tell ffmpeg builder where your include and lib files can be found (other than the usual folders).

Hopefully, we now have ffmpeg compiled and libx264 enabled. You may (and probably will) receive an error message like this:

error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

This is because ffmpeg is looking for it's libraries in the usual place (most probably /usr/lib). In order to get it working, you have to set the enviroinment variable LD_LIBRARY_PATH TO /home/<USERNAME>/lib. This can be done via command line with the following command:

export LD_LIBRARY_PATH=/home/<USERNAME>/lib

Now you should be able to convert videos using the x264 library. Remember that the libx264 library requires you to parametrize the encoding using a preset file. In my case, i had _serious_ problems using the usual procedure, which would be something like this:

./ffmpeg -i input.file -y -ar 44100 -pass 2 -vcodec libx264 -b 810k -vpre normal -threads 0 output.file
The output will be something like
File for preset 'normal' not found

So I used -fpre instead of -vpre, which accepts a file as parameter, so I can use something like

-fpre "/home/<USERNAME>/libx264-medium.ffpreset"

Note: the main reason for me to use a custom ffmpeg and libx264 installation is that the ffmpeg version installed does not accept the -fpre parameters, only the -vpre, so I could not find the preset files. Searched a lot and it'd never for for me.

See also