http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=55225
참고삼아 설치를 시작했다.
20080926 10:00:00

 
reference : http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-%e2%80%93-the-easy-way/

설치 참고 자료를 가지고 전에 한번 테스트 실패했는데 오늘 여기 저기 확인 해보면서 설치 성공 했네요 ^^

설치 테스트 환경
OS : CentOS 5
APM패키지: 기본 설치한 RPM 버전

아래 설치 문서는 위 참조사이트의 내용을 골격으로 하고 있으며 본인의 설치 환경에 맞춘것 입니다.
------------------------------------------------------------------------------------------------------------------------
1. Create a directory to do our work in
mkdir ~/ffmpeg
cd ~/ffmpeg
 ==> mkdir /usr/local/src/ffmpeg/

2. Get all the source files
wget http://www3.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://easynews.dl.sourceforge.net/sourceforge/ lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ ffmpeg-php/ffmpeg-php-0.5.0.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://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
  wget
http://www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20071007.tar.bz2
 
  wget
http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
  wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
 
  wget
http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
  lame-398-2.tar.gz 은 웹에서 받아 ftp로 올림

  wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
  ffmpeg-php-0.5.3.1.tbz2 웹에서 받아 ftp로 올림

  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://downloads.xiph.org/releases/vorbis/libvorbis-1.2.0.tar.gz


3. Extract all the source files
bunzip2 essential-20061022.tar.bz2; tar xvf essential-20061022.tar
tar zxvf flvtool2_1.0.5_rc6.tgz
tar zxvf lame-3.97.tar.gz
bunzip2 ffmpeg-php-0.5.0.tbz2; tar xvf ffmpeg-php-0.5.0.tar
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
 ==>
 /usr/local/src/ffmpeg 에 받은 파일을 /usr/local/ffmpeg 로 카피
 mkdir /usr/local/ffmpeg
 cp essential-20071007.tar.bz2 ../../ffmpeg/
 cp ffmpeg-php-0.5.3.1.tbz2 ../../ffmpeg/
 cp flvtool2-1.0.6.tgz ../../ffmpeg/
 cp lame-398-2.tar.gz ../../ffmpeg/
 cp libogg-1.1.3.tar.gz ../../ffmpeg/
 cp libvorbis-1.2.0.tar.gz ../../ffmpeg/

 그리고 압축 풂
 tar xvpfj essential-20071007.tar.bz2
 tar xvpfj ffmpeg-php-0.5.3.1.tbz2
 tar xvpfz flvtool2-1.0.6.tgz
 tar xvpfz libvorbis-1.2.0.tar.gz
 tar xvpfz lame-398-2.tar.gz
 tar xvpfz libogg-1.1.3.tar.gz

4. Create the codecs directory & import them
mkdir /usr/local/lib/codecs/
mv essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
 ==>
  mkdir /usr/local/lib/codecs/
  mv essential-20071007/* /usr/local/lib/codecs/
  chmod -R 755 /usr/local/lib/codecs/

5. Install SVN/Ruby (Depends on OS, this is for RHEL/CentOS)
yum install subversion
yum install ruby
yum install ncurses-devel
 ==>
 yum install ruby
 나머진 깔려 있었다  ( yum list 로 확인 )

6. Get the latest FFMPEG/MPlayer from the subversion
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
 ==>
  svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
  svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

7. Compile LAME
cd ~/ffmpeg/lame-3.97
./configure
make
make install
 ==>
 cd lame-398-2
 ./configure
 make ; make install


rpm - q libogg
#rpm 설치 파일이 존재 아래 설치하지 않음
8. Compile libOGG
cd ~/ffmpeg/libogg-1.1.3
./configure
make
make install
 ==> 이미 존재함

rpm - q libvorbis
#rpm 설치 파일이 존재 아래 설치하지 않음
9. Compile libVorbis
cd ~/ffmpeg/libvorbis-1.1.2
./configure
make
make install
 ==> 이미존재함

10. Compile flvtool2
cd ~/ffmpeg/flvtool2_1.0.5_rc6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
 ==>
 cd flvtool2-1.0.6
 ruby setup.rb config
 ruby setup.rb setup
 ruby setup.rb install

11. Compile MPlayer
cd ~/ffmpeg/mplayer
./configure
make
make install
 ==>
 cd mplayer/
 ./configure
 make ; make install

vi /etc/ld.so.conf
/usr/local/lib # 없으면 추가
ldconfig      # 추가 했다면 실행
 ==>
 vi /etc/ld.so.conf
 이후 파일 수정
 ldconfig

12. Compile FFMPEG
cd ~/ffmpeg/ffmpeg
./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
echo '#define HAVE_LRINTF 1' >> config.h
make
make install
 ==>
 ./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
 에러난다.   libogg없는 옵션이라고 한다.
 ./configure --help >1.txt
 vi 1.txt
 진짜 업다. coufigure 옵션에 libogg 가 없다 ; 빼고 다시 ..
 ./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
 echo '#define HAVE_LRINTF 1' >> config.h
 make ; make install

13. Finalize the codec setups
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/libavformat.so.52
 ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
 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

14. Compile FFMPEG-PHP
cd ~/ffmpeg/ ffmpeg-php-0.5.0
phpize    # phpize 가 없다면 옆에 실행 => yum install php-devel.i386
./configure
make
make install
 ==>
 phpize
 ./configure
 make ; make install


15. Install FFMPEG-PHP (make sure the php.ini path is correct.)
echo 'extension=/usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so' >> /usr/local/Zend/etc/php.ini
 ==>
 echo 'extension=/usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so' >> /usr/local/Zend/etc/php.ini
 에러난다. phpinfo() 로 php.ini 파일 위치 확인
 echo 'extension=/usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so' >> /etc/php.ini

16. Restart Apache to load FFMPEG-PHP (Depends on OS, this is for RHEL/CentOS)
service httpd restart
 ==>
  service httpd restart

17. Verify if it works
php -r 'phpinfo();' | grep ffmpeg

If you get a few lines such as
ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0
 ==>
 [root@ns3 ffmpeg]#  php -r 'phpinfo();' | grep ffmpeg
 PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules//usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so' - /usr/lib/php/modules//usr/local/lib/php/extensions/ no-debug-non-zts-20020429/ffmpeg.so: cannot open shared object file: No such file or directory in Unknown on line 0
 OLDPWD => /usr/local/ffmpeg
 PWD => /usr/local/src/ffmpeg
 _SERVER["OLDPWD"] => /usr/local/ffmpeg
 _SERVER["PWD"] => /usr/local/src/ffmpeg
 _ENV["OLDPWD"] => /usr/local/ffmpeg
 _ENV["PWD"] => /usr/local/src/ffmpeg
 아놔 ;; 짜증나 ㅡㅜ
 일단 의심은
 1. /usr/lib/php 폴더가 없다.
 2. Zend가 없다. Zend 깔아 보고.. 그러면 /usr/local/Zend/etc/php.ini가 될테니..

# 위와 같이 보이면 성공

Then everything is installed and working. FFMPEG, FFMPEG-PHP, MPlayer, MEncoder, flv2tool, LAME MP3 encoder & libOGG.

# 17번에서 Error:cannot restore segment prot after reloc: Permission denied 이런 메세지가 있으면..
vi /etc/sysconfig/selinux
SELINUX=enforcing

위와 같은 설정이 있다면 위부분을
SELINUX=disabled 로 변경
시스템 부팅 selinux가 커널쪽에 무슨 설정이 있다고 합니다 그래서 리붓

차후 확인 php -r 'phpinfo();' | grep ffmpeg 정상적으로 보임


[테스트]
ffmpeg -i video.wmv -ar 22050 -ab 32 -f flv -s 320x240 video.flv | flvtool2 -U stdin video.flv

FLV변환 자료 확인

고운하루 보내세요 

참고 문서 : http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=55225

신고
Posted by 멍그


티스토리 툴바