📜 ⬆️ ⬇️

Building ffmpeg on CentOS 6.0 x64 for Web video mp4, webm, ogv

Working with one project, I faced the need to upload videos to the server (quality videos lasting 2-3 minutes), followed by replicating them to S3 & distribution via CouldFront. On the hosting costs Centos 6.0 x64. ffmpeg which is in additional repositories unfortunately shaggy version 6.1 and does not include vp8 and its ilk. So I had to do a hand-made assembly. Unfortunately I didn’t find an intelligent guide after fiddling around on an Internet site, so I read a guide on VirtualBox for myself in the district on this topic. I would be glad if someone come in handy. The libraries were chosen 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. To begin, update all the 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 a path to search for libraries 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.
Required library for libx264
 cd yasm ./autogen.sh && make && make install 


Add libraries to work 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 


Then the video went:
 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 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 tells you more optimal.

Source: https://habr.com/ru/post/132495/


All Articles