Build ffmpeg on CentOS 6.0 x64 for web videos mp4, webm, ogv
Working with one project, I was faced with the need to upload videos to the server (quality videos lasting 2-3 minutes), followed by their replication to S3 & distribution through CouldFront. On hosting costs Centos 6.0 x64. ffmpeg which in additional repositories unfortunately is shaggy version 6.1 and does not include vp8 and its ilk. Therefore, I had to deal with my own assembly. Unfortunately I didn’t find a sensible guide on the Internet, so after reading in the area on this topic I skated a guide to VirtualBox for myself. I would be glad if someone comes in handy. Libraries were selected last at the beginning of November.
I will describe the installation on a clean server. Some of the components that I used for my needs (mysql, httpd, etc) I threw away. First, update all packages and install the necessary from the standard repository
Add the path to the library search in the config:
Download the necessary sources:
Unpack:
Well, we begin to collect.
Necessary library for libx264
Add libraries for working with sound:
Next went the video:
In theory, after all the steps, you should have the latest version of the working ffmpeg installed:
For conversion, we use the following flags:
OGV
Webm
Mp4
I would be glad if someone prompts more optimal ones.
I will describe the installation on a clean server. Some of the components that I used for my needs (mysql, httpd, etc) I threw away. First, update all packages and install the necessary from the standard repository
yum update && yum upgrade
yum install git wget man mlocate gcc gcc-c++ make check-devel libogg
yum groupinstall "Development Tools" -y
Add the path to the library search in the config:
echo /usr/local/lib >/etc/ld.so.conf.d/local.conf
Download the necessary sources:
cd /usr/local/src
git clone git://github.com/yasm/yasm.git yasm
git clone http://git.chromium.org/webm/libvpx.git libvpx
git clone git://git.videolan.org/ffmpeg.git ffmpeg
git clone git://git.videolan.org/x264.git libx264
wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.bz2
wget http://sourceforge.net/projects/faac/files/faac-src/faac-1.28/faac-1.28.tar.gz
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.1.tar.gz
wget http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz
Unpack:
tar -xvf faad2-2.7.tar.bz2
tar -xvf faac-1.28.tar.gz
tar xf lame-3.99.1.tar.gz
tar xfv libtheora-1.1.1.tar.gz
tar xfv libvorbis-1.3.2.tar.gz
Well, we begin to collect.
Necessary library for libx264
cd yasm
./autogen.sh && make && make install
Add libraries for working with sound:
cd ../faad2-2.7
./configure --with-mp4v2
make clean && make && make install
cd ../faac-1.28
./configure --with-mp4v2
vi common/mp4v2/mpeg4ip.h
#comment line 126
#:126
#/*char *strcasestr(const char *haystack, const char *needle);*/
make clean && make && make install
cd ../lame-3.99.1
./configure
make clean && make && make install
cd ../libvorbis-1.3.2
./configure
make clean && make && make install
cd ../libtheora-1.1.1
./configure
make clean && make && make install
Next went the video:
cd ../libvpx
./configure --target=x86_64-linux-gcc --enable-pic --enable-vp8 --enable-shared
make clean && make && make install
cd ../libx264/
./configure --enable-shared --enable-static --prefix=/usr
make clean && make && make install
cd ../ffmpeg/
./configure --prefix=/usr --enable-shared --enable-libfaac --enable-libvpx --enable-libx264 --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-pic --enable-gpl --enable-nonfree
make clean && make && make install
ldconfig -v
In theory, after all the steps, you should have the latest version of the working ffmpeg installed:
[root@ffmpeg ffmpeg]# ffmpeg
ffmpeg version N-34650-g083d9ba, Copyright (c) 2000-2011 the FFmpeg developers
built on Nov 11 2011 00:00:37 with gcc 4.4.4 20100726 (Red Hat 4.4.4-13)
configuration: --prefix=/usr --enable-shared --enable-libfaac --enable-libvpx --enable-libx264 --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-pic --enable-gpl --enable-nonfree
libavutil 51. 24. 1 / 51. 24. 1
libavcodec 53. 31. 0 / 53. 31. 0
libavformat 53. 20. 0 / 53. 20. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 47. 2 / 2. 47. 2
libswscale 2. 1. 0 / 2. 1. 0
libpostproc 51. 2. 0 / 51. 2. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
For conversion, we use the following flags:
OGV
ffmpeg -i test.avi -acodec libvorbis -ab 192k -ac 2 -ar 44100 -b 1500k -s 1280x720 test.cvt.ogv
Webm
ffmpeg -i test.avi -acodec libvorbis -ab 192k -ac 2 -ar 44100 -b 1500k -s 1280x720 test.cvt.webm
Mp4
ffmpeg -i test.avi -ab 192k -ac 2 -ar 44100 -b 1500k -s 1280x720 -level 21 -refs 2 -bt 1500k test.cvt.mp4
I would be glad if someone prompts more optimal ones.