[스트리밍] FFMPEG 설치하기

1. Create a directory to do our work in
mkdir ~/ffmpeg
cd ~/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-20071007.tar.bz2

wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz

wget http://downloads.sourceforge.net/lame/lame-3.97.tar.gz?modtime=1159107882&big_mirror=0

wget http://downloads.sourceforge.net/ffmpeg-php/ffmpeg-php-0.5.1.tbz2?modtime=1181869403&big_mirror=0

wget http://downloads.xiph.org/releases/ogg/libogg-1.1.tar.gz



3. Extract all the source files
tar xvfj essential-20061022.tar.bz2
tar xvfz flvtool2_1.0.5_rc6.tgz
tar xvfz lame-3.97.tar.gz
tar xvfj ffmpeg-php-0.5.0.tbz2
tar xvfz libogg-1.1.3.tar.gz
tar xvfz libvorbis-1.1.2.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/


5. Install SVN/Ruby (Depends on OS, this is for RHEL/CentOS)
yum -y install subversion
yum -y install ruby ruby-devel
yum -y install ncurses-devel


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


7. Compile LAME
cd ~/ffmpeg/lame-3.97
./configure
make
make install


rpm -qa | grep libogg ; rpm -qa | grep libogg-devel
#rpm 설치 파일이 존재하면 아래 설치하지 않음
8. Compile libOGG
cd ~/ffmpeg/libogg-1.1.3
./configure
make
make install


rpm -qa | grep libvorbis ; rpm -qa | grep libvorbis-devel

#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


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

vi /etc/ld.so.conf
/usr/local/lib # 없으면 추가
ldconfig      # 추가 했다면 실행


12. Compile FFMPEG
cd ~/ffmpeg/ffmpeg
./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/libavformat.so.52.7.0 /usr/lib/libavformat.so.52
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


14. Compile FFMPEG-PHP

# phpize 가 없다면 옆에 실행 = > yum -y install php-devel
cd ~/ffmpeg/ ffmpeg-php-0.5.0
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


16. Restart Apache to load FFMPEG-PHP (Depends on OS, this is for RHEL/CentOS)
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

# 위와 같이 보이면 성공

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 320×240 video.flv | flvtool2 -U stdin video.flv

서진우

슈퍼컴퓨팅 전문 기업 클루닉스/ 상무(기술이사)/ 정보시스템감리사/ 시스존 블로그 운영자

You may also like...

페이스북/트위트/구글 계정으로 댓글 가능합니다.