Anda di halaman 1dari 7

membuat server streaming ala youtube

cara membuat streaming server :

alat dan bahan :

alat :

- server Linux Ubuntu yang telah di install PHP MYSQL apache2 (LAMPD)

- bandwith yang gede buat streaming nya

bahan :

- mod_flv_streaming module (untuk streaming file .flv )

- mod_secdownload module (biar nggak bisa di link ke tempat laen "ala youtube")

- PHPMotion player gratis yang bisa muter video ala youtube

warning.......... jika tidak berpengalaman dengan linux mendingan jangan coba-coba


deh..... nanti capek sendiri

di sini juga di tunjukkan cara meng "encode" video dari .mp4 .mov .mpg .3gp .mpeg
.wmv .avi ke .flv

Langkah-langkah :

1. instal LAME

lame digunakan untuk MPEG Audio Layer III (MP3) encoder agar video tidak
kehilangan suara

root@vro-server:~# cd /usr/local/src/
root@vro-server:/usr/local/src# wget http://nchc.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
root@vro-server:/usr/local/src# ls |grep lame

lame-3.97.tar.gz
root@vro-server:/usr/local/src#

root@vro-server:/usr/local/src# tar xvfz lame-3.97.tar.gz


root@vro-server:/usr/local/src# cd lame-3.97
root@vro-server:/usr/local/src/lame-3.97# ./configure --enable-shared --prefix=/usr
root@vro-server:/usr/local/src/lame-3.97# make
root@vro-server:/usr/local/src/lame-3.97# make install

2. instal ffmpg untuk mengkonvert ke .flv

sebelum install ffmpg nya install dulu plug-in nya

root@vro-server:/usr/local/src/lame-3.97# apt-get install ffmpeg libavcodec0d libavformat0d libavifile-0.7c2


libasound2-plugins avifile-player avifile-utils avifile-mad-plugin avifile-mjpeg-plugin avifile-vorbis-plugin

kemudian download file asli nya ffmpg dan edit connflags nya

root@vro-server: cd /usr/local/src/
root@vro-server:/usr/local/src# : apt-get source ffmpeg

root@vro-server: cd ffmpeg-0.cvs20060823

root@vro-server:/usr/local/src/ffmpeg-0.cvs20060823# vi debian/rules

tambahkan --enable-mp3lame di file rules

[..........]

confflags += --enable-gpl --enable-pp --enable-pthreads --enable-mp3lame


confflags += --enable-vorbis --enable-libogg --enable-a52 --enable-dts --enable-libgsm

[.........]

setelah itu re-packages ffmpg nya

root@vro-server:/usr/local/src/ffmpeg-0.cvs20060823# dpkg-buildpackage
dpkg-buildpackage: source package is ffmpeg
dpkg-buildpackage: source version is 0.cvs20060823-8
dpkg-buildpackage: source changed by Sam Hocevar (Debian packages) <sam+deb@zoy.org>
dpkg-buildpackage: host architecture i386
dpkg-buildpackage: source version without epoch 0.cvs20060823-8
dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 4.0) quilt libogg-dev libvorbis-dev liba52-de
dev libsdl1.2-dev libfreetype6-dev libimlib2-dev texi2html libraw1394-dev libdc1394-13-dev libtheora-dev (
libgsm1-dev
dpkg-buildpackage: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: (Use -d flag to override.)

root@vro-server:/usr/local/src/ffmpeg-0.cvs20060823#

pasti banyak modules pendukung yang belum terinstall, yak ... kita install aja dulu

root@vro-server:/usr/local/src/ffmpeg-0.cvs20060823# apt-get install debhelper quilt libogg-dev libvorbis-de


dev zlib1g-dev libsdl1.2-dev libfreetype6-dev libimlib2-dev texi2html libraw1394-dev libdc1394-13-dev libt
dev

kemudian rebuild package lagi

root@vro-server:/usr/local/src/ffmpeg-0.cvs20060823# dpkg-buildpackage

yessssssssss.... berhasil........... sambil nunggu rebuild................ buat kopi dulu..................

beres untuk ffmpg. lanjuut..........

untuk mengkonvert pelem kita perlu metadata dari pelem itu (halaaah... kaya om ROY
aja metadata ahahahaha) untuk itu kita perlu RUBY dan flvtool2.

root@vro-server:/usr/local/src# apt-get install ruby

root@vro-server:/usr/local/src# wget http://rubyforge.org/frs/download.php/17497/flvtool2-1.0.6.tgz


root@vro-server:/usr/local/src# tar -zxvf flvtool2-1.0.6.tgz

root@vro-server:/usr/local/src# cd flvtool2-1.0.6
root@vro-server:/usr/local/src/flvtool2-1.0.6# ruby setup.rb config
---> bin
<--- bin
---> lib
---> lib/flvtool2
<--- lib/flvtool2
---> lib/flv
<--- lib/flv
<--- lib
root@vro-server:/usr/local/src/flvtool2-1.0.6# ruby setup.rb setup
---> bin
updating shebang: flvtool2
<--- bin
---> lib
---> lib/flvtool2
<--- lib/flvtool2
---> lib/flv
<--- lib/flv
<--- lib
root@vro-server:/usr/local/src/flvtool2-1.0.6# ruby setup.rb install
rm -f InstalledFiles
---> bin
mkdir -p /usr/bin
install flvtool2 /usr/bin/
<--- bin
---> lib
mkdir -p /usr/local/lib/site_ruby/1.8
install flv.rb /usr/local/lib/site_ruby/1.8/
install miyaml.rb /usr/local/lib/site_ruby/1.8/
install flvtool2.rb /usr/local/lib/site_ruby/1.8/
install mixml.rb /usr/local/lib/site_ruby/1.8/
---> lib/flvtool2
mkdir -p /usr/local/lib/site_ruby/1.8/flvtool2
install base.rb /usr/local/lib/site_ruby/1.8/flvtool2
install version.rb /usr/local/lib/site_ruby/1.8/flvtool2
<--- lib/flvtool2
---> lib/flv
mkdir -p /usr/local/lib/site_ruby/1.8/flv
install tag.rb /usr/local/lib/site_ruby/1.8/flv
install meta_tag.rb /usr/local/lib/site_ruby/1.8/flv
install stream.rb /usr/local/lib/site_ruby/1.8/flv
install amf_string_buffer.rb /usr/local/lib/site_ruby/1.8/flv
install core_extensions.rb /usr/local/lib/site_ruby/1.8/flv
install audio_tag.rb /usr/local/lib/site_ruby/1.8/flv
install video_tag.rb /usr/local/lib/site_ruby/1.8/flv
<--- lib/flv
<--- lib
root@vro-server:/usr/local/src/flvtool2-1.0.6#

3. membuat direktori tempat pelem

kita buat 2 direktori untuk menaro pelem. satu pelem yang belum di convert satu nya
yang udah

root@vro-server:/usr/local/src/flvtool2-1.0.6# mkdir -p /var/videos/incoming


root@vro-server:/usr/local/src/flvtool2-1.0.6# mkdir -p /var/videos/flv

di buat sperti ini supaya orang nggak bisa direct download pelem-pelem kita, user atau
kita bisa ngisi file nya lewat ftp dan bisa di encode menggunakan script.

4. Encoding file ke FLV

untuk ujicoba upload ke server kita file video berextensi avi dan letakan di
/var/videos/incoming/ untuk ujicoba ini saya menggunakan file hack.avi

root@vro-server:/usr/local/src# ffmpeg -i /var/videos/incoming/hack.avi -s 320x240 -ar 44100 -r 12 /var/vide


FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --enable-gpl --enable-pp --enable-pthreads --enable-mp3lame --enable-vorbis --enable-libogg -
dts --enable-libgsm --enable-dc1394 --disable-debug --enable-shared --prefix=/usr
libavutil version: 0d.49.0.0
libavcodec version: 0d.51.11.0
libavformat version: 0d.50.5.0
built on Jun 24 2008 06:08:01, gcc: 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
Input #0, avi, from '/var/videos/incoming/hack.avi':
Duration: 00:02:54.6, start: 0.000000, bitrate: 492 kb/s
Stream #0.0: Video: camtasia, bgr24, 800x600, 15.00 fps(r)
Stream #0.1: Audio: pcm_s16le, 22050 Hz, mono, 352 kb/s
PIX_FMT_YUV420P will be used as an intermediate format for rescaling
Output #0, flv, to '/var/videos/flv/hack.flv':
Stream #0.0: Video: flv, yuv420p, 320x240, q=2-31, 200 kb/s, 12.00 fps(c)
Stream #0.1: Audio: mp3, 44100 Hz, mono, 64 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 2096 q=2.0 Lsize= 6154kB time=174.6 bitrate= 288.7kbits/s
video:4652kB audio:1364kB global headers:0kB muxing overhead 2.283599%

okeeeee testing encode telah berhasil sekarang install emcode

root@vro-server:/usr/local/src# apt-get install mencoder

untuk player dan tampilan web nya kita gunakan phpmotion

rooroot@vro-server:/usr/local/src#cd /var/www/

rooroot@vro-server:/var/www# wget http://downloads.phpmotion.com/V2/PHPMOTION_PHP5.zip

rooroot@vro-server:/var/www# mkdir phpmot

rooroot@vro-server:/var/www#cd phpmot

rooroot@vro-server:/var/www/phpmot# mv /var/www/PHPMOTION_PHP5.zip /var/www/phpmot

rooroot@vro-server:/var/www/phpmot# unzip PHPMOTION_PHP5.zip

rooroot@vro-server:/var/www/phpmot# mv PHPMOTION_PHP5/* /var/www/phpmot/

rooroot@vro-server:/var/www/phpmot# chmod 777 db/

chmod 777 joomla/ -R


chmod 777 test.php
chmod 777 test.html
chmod 777 setup/
chmod 777 pictures/
chmod 777 classes/
chmod 777 temp
chmod 777 temp/logs/
chmod 777 addons/
chmod 777 uploads/
chmod 777 uploads/avi/
chmod 777 uploads/thumbs/
chmod 777 uploads/audio/
chmod 777 uploads/audio/temp/
chmod 777 uploads/pictures/
chmod 755 cgi-bin/ -R
chmod 755 cgi-bin/audio/ -R
chmod 777 logs/

perlu registrasi terlebih dahulu untuk mendownload phpmotion ini. setelah itu ikuti
petunjuk instalasi nya, jangan lupa file2 yang harus di CHMOD harus di ubah terlebih
dahulu.

baca baik-baik cara instalasi. setelah itu buat database untuk pelem, user dan password
nya menggunakan MySQL. kemudian buka direktori instalasi.

disini kita menggunakan ip public 202.154.183.5 maka :


http://202.154.183.5/phpmot/setup/

ikuti langkah2 nya dan pastikan semua file yang perlu di delet harus di delet dan yang
perlu di chmod 755 telah di chmod.

maka........... http://202.154.183.5/phpmot/

tadaaaaaaaaaaaaaaaaaaa selesai deeeeeeeh ............. selamat mencoba....