<Ⅰ>FFmepg-streamer
Fedoraでストリーミングサーバの定番ともいえるFFmpegによりストリーミングサーバを構築したときのメモです。
FFmpegの特長はサポートしているコーディックが多いことです。
≪Ⅰ≫FFmpeg
ストリーミングサーバのオープンソースソフトウェアであるFFmpegを導入します。
<バージョン>
FFmpegバージョン:0.5.2-1
1.事前準備
(1)yasmインストール
yasmをFFmpegのコンパイルで使用するため、yasmを ダウンロードサイト からダウンロードし、コンパイル・インストールします。
[root@honma ~]# cd /usr/local/webcamera/
[root@honma webcamera]# mv /home/thonma/ダウンロード/yasm-1.1.0.tar.gz ./
← ダウンロード先から/usr/local/webcamera/に移動
[root@honma webcamera]# tar xzf yasm-1.1.0.tar.gz
← 解凍
[root@honma webcamera]# cd yasm-1.1.0
← lameのディレクトリに移動
[root@honma yasm-1.1.0]# ./configure
← configureコマンドを実行
[root@honma yasm-1.1.0]# make
← makeコマンドを実行
[root@honma yasm-1.1.0]# make install
← インストールを実行
2.FFmpegインストール
(1)FFmpegダウンロード
FFmpegをsvnコマンドを使用してダウンロードします。
[root@honma ~]# cd /usr/local/webcamera/
[root@honma webcamera]# svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
(2)FFmpegインストール
ダウンロードしたFFmpegをインストールする。
[root@honma webcamera]# cd ffmpeg [root@honma ffmpeg]# ./configure --disable-ffplay --enable-ffserver --enable-gpl --enable-libfaac --enable-libmp3lame --enable-pthreads --enable-libx264 --enable-libxvid --enable-shared --enable-nonfree ← configureコマンドを実行 [root@honma ffmpeg]# make ← makeコマンドを実行 [root@honma ffmpeg]# make install ← インストールを実行
(3)ffsever.confの設定
FFmpegにはストリーミングサーバー「FFsever」が含まれており、設定ファイルffsever.confによりFFseverの設定を行います。
[root@honma ~]# cd /usr/local/etc/
[root@honma etc]# cp /usr/local/webcamera/ffmpeg/doc/ffserver.conf ./
← 雛形を/usr/local/etc/にコピー
[root@honma etc]# vi ffserver.conf
← ffsever.confを編集
3.ライブストリーミングの実行
(1)FFseverの起動
ストリーミングサーバーFFseverを起動する
[root@honma ~]ffserver -f /usr/local/etc/ffserver.conf &← FFseverを起動 [1] 5112 [root@honma ~]# FFserver version SVN-r24953, Copyright (c) 2000-2010 the FFmpeg developers built on Aug 29 2010 09:25:00 with gcc 4.4.1 20090725 (Red Hat 4.4.1-2) configuration: --disable-ffplay --enable-ffserver --enable-gpl --enable-libfaac --enable-libmp3lame --enable-pthreads --enable-libx264 --enable-libxvid --enable-shared --enable-nonfree libavutil 50.24. 0 / 50.24. 0 libavcore 0. 6. 0 / 0. 6. 0 libavcodec 52.87. 0 / 52.87. 0 libavformat 52.78. 3 / 52.78. 3 libavdevice 52. 2. 1 / 52. 2. 1 libavfilter 1.38. 1 / 1.38. 1 libswscale 0.11. 0 / 0.11. 0
(2)FFmpegの起動
FFmpegを起動する。
[root@honma ~]# ffmpeg -f alsa -i hw:0 -ar 22050 -ab 64000 -f video4linux2 -s 640*480 -r 30 -b 512k -i /dev/video0 http://localhost:8090/feed1.ffm← FFmpegを起動 FFmpeg version SVN-r24953, Copyright (c) 2000-2010 the FFmpeg developers built on Aug 29 2010 09:25:00 with gcc 4.4.1 20090725 (Red Hat 4.4.1-2) configuration: --disable-ffplay --enable-ffserver --enable-gpl --enable-libfaac --enable-libmp3lame --enable-pthreads --enable-libx264 --enable-libxvid --enable-shared --enable-nonfree libavutil 50.24. 0 / 50.24. 0 libavcore 0. 6. 0 / 0. 6. 0 libavcodec 52.87. 0 / 52.87. 0 libavformat 52.78. 3 / 52.78. 3 libavdevice 52. 2. 1 / 52. 2. 1 libavfilter 1.38. 1 / 1.38. 1 libswscale 0.11. 0 / 0.11. 0 [alsa @ 0x8b21470] Estimating duration from bitrate, this may be inaccurate Input #0, alsa, from 'hw:0': Duration: N/A, start: 175266.996049, bitrate: N/A Stream #0.0: Audio: pcm_s16le, 16000 Hz, 1 channels, s16, 256 kb/s [video4linux2 @ 0x8b2ae10] Estimating duration from bitrate, this may be inaccurate Input #1, video4linux2, from '/dev/video0': Duration: N/A, start: 1283863030.806355, bitrate: 147456 kb/s Stream #1.0: Video: rawvideo, yuyv422, 640x480, 147456 kb/s, 30 tbr, 1000k tbn, 30 tbc [buffer @ 0x8b2ed40] w:640 h:480 pixfmt:yuyv422 [scale @ 0x8b33ae0] w:640 h:480 fmt:yuyv422 -> w:352 h:240 fmt:yuvj420p flags:0xa0000004 [buffer @ 0x8be97b0] w:640 h:480 pixfmt:yuyv422 [scale @ 0x8bedef0] w:640 h:480 fmt:yuyv422 -> w:160 h:128 fmt:yuv420p flags:0xa0000004 [buffer @ 0x8c75cd0] w:640 h:480 pixfmt:yuyv422 [scale @ 0x8e6c540] w:640 h:480 fmt:yuyv422 -> w:352 h:240 fmt:yuv420p flags:0xa0000004 Output #0, ffm, to 'http://localhost:8090/feed1.ffm': Metadata: encoder : Lavf52.78.3 Stream #0.0: Video: mjpeg, yuvj420p, 352x240, q=2-31, 200 kb/s, 1000k tbn, 2 tbc Stream #0.1: Video: flv, yuv420p, 160x128, q=2-31, 200 kb/s, 1000k tbn, 2 tbc Stream #0.2: Audio: libmp3lame, 22050 Hz, 1 channels, s16, 64 kb/s Stream #0.3: Video: msmpeg4, yuv420p, 352x240, q=2-31, 256 kb/s, 1000k tbn, 15 tbc Stream mapping: Stream #1.0 -> #0.0 Stream #1.0 -> #0.1 Stream #0.0 -> #0.2 Stream #1.0 -> #0.3 Press [q] to stop encoding [mjpeg @ 0x8b33e80] rc buffer underflow [flv @ 0x8b34420] rc buffer underflow [msmpeg4 @ 0x8b34f60] rc buffer underflow frame= 1866 fps= 2 q=1.6 Lq=1.6 q=2.0 size= 48508kB time=932.00 bitrate= 426.4kbits/s dup=9303 drop=5622
(3)ライブストリーミングの実行(サーバー)
サーバーでインターネットの「http://localhost:8090/stat.html」にアクセスすると、ステータス一覧が表示されます。ステータス一覧の「test.swf」をクリックすると画像が表示されます。
ステータス一覧の「test.jpg」、「test.asf」をクリックしても、画像は表示されません。
Mplayerを使用すると、「test.swf」の画像を表示できます。
詳細は
「≪Ⅱ≫ Mplayer」
を参照。
<ステータス一覧>
(4)ライブストリーミングの実行(クライアント)
クライアントでインターネットの「http://サーバーのIPアドレス:8090/stat.html」にアクセスすると、ステータス一覧が表示されます。ステータス一覧の「test.jpg」をクリックすると動画が表示されず、静止画が表示されます。
ステータス一覧の「test.swf」、「test.asf」をクリックしても、画像は表示されません。
SMplayerを使用すると、「test.swf」、「test.asf」の画像を表示できます。
詳細は
「≪Ⅲ≫ SMplayer」
を参照。
<ステータス一覧>
Copyright© 2007 Honma Internet Technology Laboratory, All rights reserved.
このサイトに関するご意見・ご要望、誤字・脱字などはこちらまでお寄せください。