FFMPEG Installation compile build

https://kattafix.wordpress.com/2013/06/03/ffmpeg-installation/


FFMPEG Installation

Manual Installation of FFMPEG

The following Guide will show you exactly how to install the following packages on a CentOS system:

  • FFmpeg
  • FFmpeg-PHP
  • Mplayer + Mencoder
  • flv2tool
  • LAME MP3 Encoder
  • AMR (for 3gp file conversions)
  • Libogg
  • Libvorbis

Setup the directory to use

mkdir /usr/local/src
cd /usr/local/src

Download the necessary files.

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://downloads.sourceforge.net/lame/lame-3.97.tar.gz
wget http://en.sourceforge.jp/frs/g_redir.php?m=jaist&f=%2Fffmpeg-php%2Fffmpeg-php%2F0.5.1%2Fffmpeg-php-0.5.1.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-6.1.0.4.tar.bz2
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-6.0.0.1.tar.bz2

Extract all the files

tar zxvf flvtool2_1.0.5_rc6.tgz
tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-20061022.tar.bz2
tar jxvf ffmpeg-php-0.5.1.tbz2
tar jxvf amrwb-6.0.0.1.tar.bz2
tar jxvf amrnb-6.1.0.4.tar.bz2

Create a folder to hold the codecs

mkdir /usr/local/lib/codecs/

Make sure we have all the necessary libraries as well as SVN + Ruby installed

yum -y install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran subversion ruby ncurses-devel

Install subversion via rpm.

http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/

wget http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/apr-0.9.12-1.i386.rpm
wget http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/apr-util-0.9.12-1.i386.rpm
wget http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/apr-devel-0.9.12-1.i386.rpm
wget http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/apr-util-devel-0.9.12-1.i386.rpm
wget http://the.earth.li/pub/subversion/summersoft.fay.ar.us/pub/subversion/latest/rhel-4/i386/subversion-1.4.5-1.i386.rpm

Get ffmpeg and mplayer via SVN

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src

Copy Codes for Mplayer

mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

Create a temp dir with 777 permissions (needed to install ffmpeg)

mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp

Installing LAME

cd /usr/local/src/lame-3.97
./configure
make && make install
cd /usr/local/src/

Installing LIBOGG:

cd /usr/local/src/libogg-1.1.3
./configure && make && make install
cd /usr/local/src/

Installing LIBVORBIS:

cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install
cd /usr/local/src/

Installing FLVTOOL2:

cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd /usr/local/src/
cd /usr/local/src/mplayer
./configure && make && make install
cd /usr/local/src/

Installing AMR (for 3GP Conversion)

cd /usr/local/src/amrnb-6.1.0.4
./configure
make && make install
cd /usr/local/src/amrwb-6.0.0.1
./configure
make && make install

Installing FFMPEG:

cd /usr/local/src/ffmpeg/
./configure --enable-libmp3lame --enable-libogg --enable-libamr-nb --enable-libamr-wb --enable-libvorbis --disable-mmx --enable-shared
make
make install
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/
ln -s /usr/local/lib/libamrnb.so.2 /usr/lib/
ln -s /usr/local/lib/libamrwb.so.2 /usr/lib/
ln -s /usr/local/lib/libvorbisenc.so.2 /usr/lib/
ln -s /usr/local/lib/libvorbis.so.0 /usr/lib/

ffmpeg -version

cd /usr/local/src/

Installing FFMPEG-PHP:

cd /usr/local/src/ffmpeg-php-0.5.0/
phpize
./configure
make
make install

Note: Make sure this is the correct php.ini for the box!!

echo 'extension=ffmpeg.so' >> /usr/local/lib/php.ini

Restart and you’re done

service httpd restart
cd /usr/local/src

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg/
./configure --enable-shared
make
make install
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
bunzip2 ffmpeg-php-0.5.0.tbz2
tar xvf ffmpeg-php-0.5.0.tar
cd ffmpeg-php-0.5.0
phpize

./configure

make
make install

Add the following line to php.ini

extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so
service httpd restart

Testing

Direct your browser to view a phpinfo() php file. Scroll down and you should see the ffmpeg extension.

[edit]Errors faced

1. If in the ./configure step following error occurs: Enable to create and execute files in /tmp. Set the TMPDIR environment variable to another directory and make sure that /tmp is not mounted noexec. Sol:

mkdir ffmpeg/tmp
chmod 777 ffmpeg/tmp
vi configure

change TMPDIR from /tmp to tmp tmp dir we make should be inside the directory ffmpeg/

2. ffmpeg: symbol lookup error: ffmpeg: undefined symbol: avcodec_alloc_context2

Sol:- Add /usr/local/lib to etc/ld.so.conf and then run

ldconfig

3. make[1]: *** [stream_dvd.o] Error 1 make[1]: Leaving directory `/usr/local/src/mplayer/stream’ make: *** [stream/stream.a] Error 2

Sol: –

cd /us/local/src
wget http://www3.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc2.tar.bz2
tar -jxf MPlayer-1.0rc2.tar.bz2
cd MPlayer-1.0rc2
./configure
make
make install

4. Installing Subversion Using yum on CentOS 5 (Error: Missing Dependency: perl(URI) >= 1.17 is needed by package subversion)

yum install subversion
–> Finished Dependency Resolution
Error: Missing Dependency: perl(URI) >= 1.17 is needed by package subversion

Sol:- check the yum.conf to see if there is line like this. If yes, commnet it and instgall subversion using yum.

exclude=apache* bind-chroot courier* dovecot* exim* httpd* mod_ssl* mysql* nsd* perl* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail*

wget ftp://rpmfind.net/linux/fedora/releases/8/Everything/ppc64/os/Packages/perl-URI-1.35-3.1.noarch.rpm
rpm -ivh perl-URI-1.35-3.1.noarch.rpm

If 64 bit server use below.

wget ftp://rpmfind.net/linux/fedora/releases/8/Everything/x86_64/os/Packages/perl-URI-1.35-3.1.noarch.rpm

5. checking for ffmpeg headers… configure: error: ffmpeg headers not found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option

Sol:

strace -f -o /root/file ./configure

check in /root/file for error:

13062 stat64("/usr/local/include/ffmpeg/avcodec.h", (No such file or directory)

do below

ln -s /usr/local/include/libavcodec/ /usr/local/include/ffmpeg

then run ./configure again

6. /usr/local/src/ffmpeg-php-0.5.0/ffmpeg-php.c:26:22: error: avformat.h: No such file or directory /usr/local/src/ffmpeg-php-0.5.0/ffmpeg-php.c: In function ‘zm_startup_ffmpeg’: /usr/local/src/ffmpeg-php-0.5.0/ffmpeg-php.c:118: error: for each function it appears in.) make: *** [ffmpeg-php.lo] Error 1 Sol:

cp /usr/include/libavformat/* /usr/local/include/php/

7. checking for ffmpeg headers… configure: error: ffmpeg headers not found. Make sure you’ve built ffmpeg as shared libs using the –enable-shared option

ffmpeg -version

The configs should show up. After confirming that you have –enable-shared there, then try the following:

The exact error happens when you phpize the php-ffmpeg file. The error goes something like this:

checking for gawk… gawk
checking for ffmpeg support… yes, shared
checking for ffmpeg headers… configure: error: ffmeg headers not found. Make sure you’ve bult ffmpeg as shared libs using the –enable-shared option

It means basically that the shared files that are requried aren’t in their correct locations. php-ffmpeg is checking /usr/local/include/ffmpeg location and yours are in the /usr/local/include directory. Silly I know, but at least its easily fixed. Run the following commands which copies the files to the new location:

cp /usr/local/include/libavcodec/* /usr/local/include/ffmpeg
cp /usr/local/include/libavutil/* /usr/local/include/ffmpeg
cp /usr/local/include/libavformat/* /usr/local/include/ffmpeg
cp /usr/local/include/libavdevice/* /usr/local/include/ffmpeg
cp /usr/local/include/libswscale/* /usr/local/include/ffmpeg

If you don’t have the libswscale directory don’t loose sleep over it, just ignore it!

8. php -v showing php: symbol lookup error: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined symbol:av_free_static

Sol: > For reference, I just went into the ffmpeg-php.c file and commented > out the one instance of av_free_static (its a method call) and rebuilt > and everything worked!

commenting "av_free_static()" in ffmpeg-php.c worked for me also

9. While installing FFMPEG on a server when we run “make” after “./configure” it gives following error:

math-errno -c -o libavdevice/v4l.o libavdevice/v4l.c
In file included from libavdevice/v4l.c:32:
/usr/include/linux/videodev.h:56: error: syntax error before "ulong"
/usr/include/linux/videodev.h:72: error: syntax error before '}' token
libavdevice/v4l.c:77: warning: unused variable `tuner'
make: *** [libavdevice/v4l.o] Error 1

Sol:-

a. First do below. If not working try the next solution.

vi /usr/include/linux/videodev.h

Search for the line below

ulong rangelow, rangehigh; /* Tuner range */

Change:

unsigned long rangelow, rangehigh; /* Tuner range */

b. This problem can be fixed by disabling v41 and v42 for FFMPEG. This can be done when we run “./configure” for FFMPEG

./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared --disable-demuxer=v4l --disable-demuxer=v4l2

10. php -v shows the following error

ffmpeg.so: undefined symbol: avcodec_build

Sol:-

edit the file ffmpeg-php.c in the source and compile again

avcodec_build (), CONST_CS | CONST_PERSISTENT);

to

LIBAVCODEC_BUILD, CONST_CS | CONST_PERSISTENT);

11.

/root/paresh/ffmpeg-php-0.5.3.1/ffmpeg_frame.c:448: error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function)
/root/paresh/ffmpeg-php-0.5.3.1/ffmpeg_frame.c: In function ‘zif_ffmpeg_frame’:
/root/paresh/ffmpeg-php-0.5.3.1/ffmpeg_frame.c:533: error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1

Sol:-

vi ffmpeg_frame.c
%s/PIX_FMT_RGBA32/PIX_FMT_RGBA/gwget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
/usr/bin/phpize
./configure
make
make install

add extrension in the Zend section

extension=ffmpeg.so

12.

/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/libavcodec.a(libx264.o): In function `X264_init':
/opt/libavfilter/ffmpeg/libavcodec/libx264.c:305: undefined reference to `x264_encoder_open_110'
collect2: ld returned 1 exit status
make: *** [x264] Error 1

OR

libavcodec.so: undefined reference to `x264_encoder_open_115'

Sol:-

yum install git
cd /usr/src
git clone git://git.videolan.org/x264.git
cd  x264
./configure --enable-shared --prefix=/usr
make
make install

If arch is x86_64 do the following and run ffmpeg make command

unlink /usr/lib64/libx264.so
ln -s /usr/lib/libx264.so /usr/lib64/libx264.so

13. make error in ffmpeg-php

/usr/src/ffmpeg-php-0.6.1/ffmpeg-php.c:46:21: error: swscale.h: No such file or directory
/usr/src/ffmpeg-php-0.6.1/ffmpeg-php.c: In function 'zm_info_ffmpeg':
/usr/src/ffmpeg-php-0.6.1/ffmpeg-php.c:164: error: 'LIBSWSCALE_IDENT' undeclared (first use in this function)
/usr/src/ffmpeg-php-0.6.1/ffmpeg-php.c:164: error: (Each undeclared identifier is reported only once
/usr/src/ffmpeg-php-0.6.1/ffmpeg-php.c:164: error: for each function it appears in.)
make: *** [ffmpeg-php.lo] Error 1

Sol:-

cp /usr/local/include/ffmpeg/libswscale/swscale.h  /usr/local/include/ffmpeg/

Run “make” command again
14. ffmpeg configure error

ERROR: libtheora not found

Sol:-

wget  http://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2
tar -jxf  libtheora-1.1.1.tar.bz2
cd libtheora-1.1.1
./configure --prefix=/usr
make
make install

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值