[스트리밍] RHEL4 기반 ffmpeg 를 이용한 스트리밍 서비스 구축하기
1. LAME 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libmp3lame0-3.97-16.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/lame-devel-3.97-16.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/lame-3.97-16.el4.at.i386.rpm
rpm -ivh libmp3lame0-3.97-15.el4.at.i386.rpm
rpm -ivh lame-devel-3.97-15.el4.at.i386.rpm
rpm -ivh lame-3.97-15.el4.at.i386.rpm
2. libOGG 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libogg0-1.1.3-7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libogg-devel-1.1.3-7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libogg-1.1.3-7.el4.at.i386.rpm
rpm -ivh libogg0-1.1.3-7.el4.at.i386.rpm
rpm -ivh libogg-devel-1.1.3-7.el4.at.i386.rpm
rpm -ivh libogg-1.1.3-7.el4.at.i386.rpm
3. libVorbis 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libvorbis-1.1.2-5.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libvorbis0-1.1.2-5.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libvorbisenc2-1.1.2-5.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libvorbisfile3-1.1.2-5.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libvorbis-devel-1.1.2-5.el4.at.i386.rpm
rpm -ivh libvorbis-1.1.2-5.el4.at.i386.rpm
rpm -ivh libvorbis0-1.1.2-5.el4.at.i386.rpm
rpm -ivh libvorbisenc2-1.1.2-5.el4.at.i386.rpm
rpm -ivh libvorbisfile3-1.1.2-5.el4.at.i386.rpm
rpm -ivh libvorbis-devel-1.1.2-5.el4.at.i386.rpm
4. alsa-lib 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libasound2-1.0.13-32.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/alsa-lib-devel-1.0.13-32.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/alsa-lib-1.0.13-32.el4.at.i386.rpm
rpm -ivh libasound2-1.0.13-32.el4.at.i386.rpm
rpm -ivh alsa-lib-devel-1.0.13-32.el4.at.i386.rpm
rpm -ivh alsa-lib-1.0.13-32.el4.at.i386.rpm
5. alsa-utils 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/alsa-utils-1.0.13-22.el4.at.i386.rpm
rpm -ivh alsa-utils-1.0.13-22.el4.at.i386.rpm
6. libraw1394 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libraw1394_8-1.2.1-0_8.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libraw1394-devel-1.2.1-0_8.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libraw1394-1.2.1-0_8.el4.at.i386.rpm
rpm -ivh libraw1394_8-1.2.1-0_8.el4.at.i386.rpm
rpm -ivh libraw1394-devel-1.2.1-0_8.el4.at.i386.rpm
rpm -ivh libraw1394-1.2.1-0_8.el4.at.i386.rpm
7. faac 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libmp4v2_0-1.25-2.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libfaac0-1.25-2.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/faac-devel-1.25-2.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/faac-1.25-2.el4.at.i386.rpm
rpm -ivh libmp4v2_0-1.25-2.el4.at.i386.rpm
rpm -ivh libfaac0-1.25-2.el4.at.i386.rpm
rpm -ivh faac-devel-1.25-2.el4.at.i386.rpm
rpm -ivh faac-1.25-2.el4.at.i386.rpm
8. libdc1394 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libdc1394_control13-1.1.0-6.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libdc1394-devel-1.1.0-6.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libdc1394-1.1.0-6.el4.at.i386.rpm
rpm -ivh libdc1394_control13-1.1.0-6.el4.at.i386.rpm
rpm -ivh libdc1394-devel-1.1.0-6.el4.at.i386.rpm
rpm -ivh libdc1394-1.1.0-6.el4.at.i386.rpm
9. x264 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libx264_54-svn20070414_2245-4.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/x264-svn20070414_2245-4.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/x264-devel-svn20070414_2245-4.el4.at.i386.rpm
rpm -ivh libx264_54-svn20070414_2245-4.el4.at.i386.rpm
rpm -ivh x264-svn20070414_2245-4.el4.at.i386.rpm
rpm -ivh x264-devel-svn20070414_2245-4.el4.at.i386.rpm
10. xvidcore 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libxvidcore4-1.1.2-10.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/xvidcore-devel-1.1.2-10.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/xvidcore-1.1.2-10.el4.at.i386.rpm
rpm -ivh libxvidcore4-1.1.2-10.el4.at.i386.rpm
rpm -ivh xvidcore-devel-1.1.2-10.el4.at.i386.rpm
rpm -ivh xvidcore-1.1.2-10.el4.at.i386.rpm
11. fontconfig-devel 다운로드 및 설치
wget http://linuxsoft.cern.ch/cern/slc4X/i386/yum/os/fontconfig-devel-2.2.3-7.i386.rpm
rpm -ivh fontconfig-devel-2.2.3-7.i386.rpm
14. xorg-x11 다운로드 및 설치
wget ftp://ftp.nluug.nl/pub/os/Linux/distr/CentOS/4.4/updates/x86_64/RPMS/xorg-x11-devel-6.8.2-1.EL.13.37.5.i386.rpm
rpm -ivh xorg-x11-devel-6.8.2-1.EL.13.37.5.i386.rpm
12. SDL 다운로드 및 설치
wget ftp://ftp.nluug.nl/pub/os/Linux/distr/CentOS/4.4/os/x86_64/CentOS/RPMS/SDL-1.2.7-8.i386.rpm
wget ftp://ftp.nluug.nl/pub/os/Linux/distr/CentOS/4.4/os/i386/CentOS/RPMS/SDL-devel-1.2.7-8.i386.rpm
rpm -ivh SDL-1.2.7-8.i386.rpm
rpm -ivh SDL-devel-1.2.7-8.i386.rpm
13. libungif 다운로드 및 설치
wget ftp://fr2.rpmfind.net/linux/fedora/core/3/i386/os/Fedora/RPMS/libungif-4.1.3-1.i386.rpm
wget ftp://fr2.rpmfind.net/linux/fedora/core/3/i386/os/Fedora/RPMS/libungif-devel-4.1.3-1.i386.rpm
wget ftp://fr.rpmfind.net/linux/fedora/core/3/i386/os/Fedora/RPMS/libungif-progs-4.1.3-1.i386.rpm
rpm -ivh libungif-4.1.3-1.i386.rpm
rpm -ivh libungif-devel-4.1.3-1.i386.rpm
rpm -ivh libungif-progs-4.1.3-1.i386.rpm
14. imlib2 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/imlib2-1.3.0-6.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/imlib2-devel-1.3.0-6.el4.at.i386.rpm
rpm -ivh imlib2-1.3.0-6.el4.at.i386.rpm
rpm -ivh imlib2-devel-1.3.0-6.el4.at.i386.rpm
15. faad2 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/faad2-2.5-7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/faad2-devel-2.5-7.el4.at.i386.rpm
rpm -ivh faad2-2.5-7.el4.at.i386.rpm
rpm -ivh faad2-devel-2.5-7.el4.at.i386.rpm
16. libtheora 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libtheora0-1.0-8_alpha7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libtheora-devel-1.0-8_alpha7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libtheora-1.0-8_alpha7.el4.at.i386.rpm
rpm -ivh libtheora0-1.0-8_alpha7.el4.at.i386.rpm
rpm -ivh libtheora-devel-1.0-8_alpha7.el4.at.i386.rpm
rpm -ivh libtheora-1.0-8_alpha7.el4.at.i386.rpm
17. liba52 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/liba52_0-0.7.4-7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/a52dec-devel-0.7.4-7.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/a52dec-0.7.4-7.el4.at.i386.rpm
rpm -ivh liba52_0-0.7.4-7.el4.at.i386.rpm
rpm -ivh a52dec-devel-0.7.4-7.el4.at.i386.rpm
rpm -ivh a52dec-0.7.4-7.el4.at.i386.rpm
19. ffmpeg 다운로드 및 설치
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libavutil49-0.4.9-23_r8743.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libpostproc51-0.4.9-23_r8743.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libavcodec51-0.4.9-23_r8743.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/libavformat51-0.4.9-23_r8743.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/ffmpeg-devel-0.4.9-19_r7407.el4.at.i386.rpm
wget http://dl.atrpms.net/el4-i386/atrpms/stable/ffmpeg-0.4.9-19_r7407.el4.at.i386.rpm
rpm -ivh libavutil49-0.4.9-23_r8743.el4.at.i386.rpm
rpm -ivh libpostproc51-0.4.9-23_r8743.el4.at.i386.rpm
rpm -ivh libavcodec51-0.4.9-23_r8743.el4.at.i386.rpm
rpm -ivh libavformat51-0.4.9-23_r8743.el4.at.i386.rpm
rpm -ivh ffmpeg-devel-0.4.9-19_r7407.el4.at.i386.rpm
rpm -ivh ffmpeg-0.4.9-19_r7407.el4.at.i386.rpm
20. ruby 다운로드 및 설치
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar zxf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure
make
make install
cd ..
21. flvtool2 다운로드 및 설치
wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz
tar zxf flvtool2-1.0.6.tgz
cd flvtool2-1.0.6
cd /usr/local/src/ffmpeg/flvtool2_1.0.5_rc6
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd ..
22. FFMPEG-PHP 컴파일 및 설치
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
bunzip2 ffmpeg-php-0.5.0.tbz2; tar xf ffmpeg-php-0.5.0.tar
cd ffmpeg-php-0.5.0
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config
make
mkdir /usr/local/php/lib/php/extensions
cp modules/ffmpeg.so /usr/local/php/lib/php/extensions/
echo ‘extension_dir = “/usr/local/php/lib/php/extensions”‘ >> /usr/local/Zend/etc/php.ini
echo ‘extension=ffmpeg.so’ >> /usr/local/Zend/etc/php.ini
php -v 에서 에러가 없다면.. 모듈 추가 완료된 것이다.
apachectl restart
23. FFMPEG-PHP 설치및 설정 확인
php -r ‘phpinfo();’ | grep ffmpeg
아래와 같은 정보가 출력되면 성공(꼭 똑같지는 않을것이다.)
ffmpeg
ffmpeg support (ffmpeg-php) => enabled
ffmpeg-php version => 0.5.0
ffmpeg.allow_persistent => 0 => 0
[참고]
http://www.ohmi.co.kr/gnu4/bbs/board.php?bo_table=linux_study&wr_id=22
http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-%e2%80%93-the-easy-way/
[실습]
1. 동영상 변환
ffmpeg -i test.mpeg test.flv
2. 동영상에서 이미지 추출
http://ffmpeg-php.sourceforge.net/apidoc.php (FFMPEG-PHP)
<?
$moviePath = “1.mpg”;
$movie = new ffmpeg_movie($moviePath);
$frame = $movie->getFrame(1000);
$imageResource = $frame->toGDImage();
imageJpeg($imageResource, “img/1.jpg”);
?>
ffmpeg -i /home/jjangu/1.asf /home/jjangu/1.flv