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.
By default, Dreamhost users have access to a shared installation of FFmpeg in the following directory:
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:
- Move to home folder:
- Create the folder for source files:
- Move to source files folder:
- 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:
- Move to source folder:
- Move to x264 folder:
- Configure application (remember to replace <USERNAME> with your SSH login name)
./configure --enable-shared --disable-asm --prefix=/home/<USERNAME>
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:
- Make sure we're in home folder:
- Move to bin folder:
- Ask x264 to help us!
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:
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.fileThe 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
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.