1)First we have to install ffmpeg (http://ffmpeg.mplayerhq.hu/)(ffmpeg 설치)
sudo apt-get install ffmpeg
2)Back up ffserver config file.(안전을 위해 백업)
sudo mv /etc/ffserver.conf /etc/ffserver.conf_backup
3)Begin new ffserver config file. (this config was taken from http://www.webmasterworld.com/video/3514671.htm and edited by me)(설정파일만들기)
sudo gedit /etc/ffserver.conf
paste into file lines below.(아래코드를 붙여 넣고)
Port 8090 # bind to all IPs aliased or not BindAddress 0.0.0.0 # max number of simultaneous clients MaxClients 1000 # max bandwidth per-client (kb/s) MaxBandwidth 10000 # Suppress that if you want to launch ffserver as a daemon. NoDaemon <Feed feed1.ffm> File /tmp/feed1.ffm FileMaxSize 5M </Feed> # FLV output - good for streaming <Stream test.flv> # the source feed Feed feed1.ffm # the output stream format - FLV = FLash Video Format flv VideoCodec flv # this must match the ffmpeg -r argument VideoFrameRate 15 # generally leave this is a large number VideoBufferSize 80000 # another quality tweak VideoBitRate 200 # quality ranges - 1-31 (1 = best, 31 = worst) VideoQMin 1 VideoQMax 5 VideoSize 352x288 # this sets how many seconds in past to start PreRoll 0 # wecams don't have audio Noaudio </Stream> # ASF output - for windows media player <Stream test.asf> # the source feed Feed feed1.ffm # the output stream format - ASF Format asf VideoCodec msmpeg4 # this must match the ffmpeg -r argument VideoFrameRate 15 # generally leave this is a large number VideoBufferSize 80000 # another quality tweak VideoBitRate 200 # quality ranges - 1-31 (1 = best, 31 = worst) VideoQMin 1 VideoQMax 5 VideoSize 352x288 # this sets how many seconds in past to start PreRoll 0 # wecams don't have audio Noaudio </Stream>
4)Start ffserver. Open terminal.
ffserver
in ffserver config file you can delete line “NoDaemon” to run ffserver as daemon.
5)Start ffmpeg video stream.
ffmpeg -r 15 -s 352x288 -f video4linux -i /dev/video0 http://localhost:8090/feed1.ffm
If there is no any errors. its done )
Now you can watch the video.
Open your favorite player and open url http://localhost:8090/test.flv or http://localhost:8090/test.asf.
If you whant to watch your stream from another computer with windows media player:
type mms://<ip adress of ffserver machine>:8090/test.asf in IE
Also you can encode video to swf, mpeg and other formats . Read ffmpeg documentation.
If your internet connection is slow, you have make VideoFrameRate lower(1-5).
For streaming to flash player (swf)(플래쉬 플레이어로 보기위해)
add this lines to the end of ffserver.conf
<Stream test.swf> Feed feed1.ffm Format swf VideoCodec flv VideoFrameRate 2 VideoBufferSize 80000 VideoBitRate 100 VideoQMin 1 VideoQMax 5 VideoSize 352x288 PreRoll 0 Noaudio </Stream>
Now you have another stream to test.sfw file then create <any name>.html file
Add this lines to it
<EMBED src="http://<ip adress of ffserver machine>:8090/test.swf" width=640 height=480 type="application/x-shockwave-flash"></EMBED>
then open it in your browser, enjoy )(즐감)