ffmpeg Archive
ffserver(ffmpeg)+UVC対応USBカメラでストリーミング配信 続き...
- 2008年5月18日 01:27
- ffmpeg
ffserver(ffmpeg)でストリーミング配信をいましたが、時間が経つと動画が止まるという症状が発生。
いろいろサイトとかを調べたらffmpegの起動オプション-r と -bをつけることがわかりました。
昔はffserver.confだけ、いじればだったんですけどね..
で、今のところ
ffmpeg -f video4linux2 -s 640x480 -r 16 -b 512k -i /dev/video0 http://localhost:8080/feed1.ffm
の起動で現象を回避することができました。
ついでに.rmでの配信はやめて.swfと.flv配信にしました。
.asfはいまだにうまくいきません。
いちおう.flvの現在の設定をメモ
今のところ一番折り合いがつく設定かも...ffmepgの起動オプションの値と合っていないのは気のせいです(笑
<Stream test.flv>
Feed feed1.ffm
Format flv
VideoCodec flv
VideoFrameRate 10
VideoBufferSize 80000
VideoBitRate 200
VideoQMin 1
VideoQMax 5
VideoSize 640x480
PreRoll 0
NoAudio
</Stream>
- Comments (Close): 0
- TrackBacks: 0
ffserver(ffmpeg)+UVC対応USBカメラでストリーミング配信
- 2008年5月11日 19:46
- ffmpeg
ffserver(ffmpeg)でUVC対応USBカメラでストリーミング配信ができたので、そのメモです。
まずはUSBカメラのドライバインストール
#svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
#cd trunk
#make
#make install
以上でUVCドライバがインストールされます。
所有している2つのUVC対応USBカメラで認識されていることを確認。
ELECOM UCAM-DLM130HWH マニュアルフォーカス
シグマ UVCA130AFWH オートフォーカス(Linux上でフォーカス機能動作確認ス機能動作確認)
ちなみに2つのカメラは同じチップを使ってました。
次にffmpegのインストールです。
最新のffmpegでは起動時にUSBカメラの認識をしてくれないのでリビジョン9778をインストールしました。SVNでオプション-r 9778をつけてダウンロードします。
#svn checkout -r 9778 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# cd ffmpeg
# ./configure
# make
# make install
設定ファイルffserver.confをコピーします。
cp /usr/local/src/ffmpeg/doc/ffserver.conf /usr/local/etc/ffserver.conf
ffserver.confを編集します。
今回配信できたのは.swf .rm形式のみ.jpgはサポート外と表示され以前は配信できていたasf形式は表示されませんでしたので引き続き設定ファイルの調整を行う予定です。
・Flash
<Stream test.swf>
Feed feed1.ffm
Format swf
VideoFrameRate 8
VideoSize 320x240
VideoBitRate 200
VideoQMin 1
VideoQMax 5
PreRoll 0
VideoIntraOnly
NoAudio
</Stream>
・RealPlayer
<Stream test.rm>
Feed feed1.ffm
Format rm
#AudioBitRate 32
VideoBitRate 128
VideoFrameRate 15
VideoGopSize 25
VideoSize 320x240
NoAudio
</Stream>
ffserverとffmpegの起動をします。
/usr/local/bin/ffserver -f /usr/local/etc/ffserver.conf &
/usr/local/bin/ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 /tmp/test.ffm
ffmpegの起動に関してはffmpeg-0.4.8の時と少し違ってます
起動後に動作チェックを行います。
.swf(Flash)に関してはffserverを起動して時間が経過をしても配信ができるのですが、.rm(RealPlayer)に関しては起動後3時間ほどで2秒ほどしか配信されなくなります。
- Comments (Close): 0
- TrackBack (Close): 0
ffmpegでストリーミングサーバを構築してライブカメラを楽しもう。
- 2003年12月 1日 00:00
- ffmpeg
USBカメラとffmepgを使って簡単お手軽、ライブストリーミングサーバを作ってみよう。
まず、USBカメラを認識させるのですが、ここでは割愛させていただきます。
今回はドライバーを新たに入れず認識できる「ELECOM UCAM-C1C30SV」を選びました。
内蔵されているチップが「OV510」というものなので、これなら大体のLinuxなら認識するのではないでしょうか?
【2007年1月更新:swf形式を追加】
【2008年4月更新:SVN形式のダウンロードとコンパイル方法・UVC対応USBカメラetc...】
ffmpegのインストール方法
ffmepgのソースをhttp://ffmpeg.sourceforge.net/から入手します。執筆時点ではver 0.4.8です。
まずはソースの展開とインストールです。展開は適当な場所で行ってください。
# tar zxfv ffmpeg-0.4.8.tar.gz
# cd ffmpeg-0.4.8
# ./configure
# make
# make install
【追記】かなり前からSVNでのダウンロードになったようです。
#svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
# cd ffmpeg
# ./configure
# make
# make install
オプション-r 【リビジョンコード】を指定することにより該当のリビジョンをダウンロードできます。
#svn checkout -r 9133 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
インストールが終わると/usr/local/bin に ffmpeg, ffplay, ffserver がコピーされます。
ffmpeg-0.4.7/doc に ffserver.conf の雛形があるので、それを/usr/local/etc/ffserver.conf へコピーして編集します。
#cp ffserver.conf /usr/local/etc/ffserver.conf
#vi /usr/local/etc/ffserver.conf
ffserver.confの設定内容です。設定に必要な部分だけを引用してあります。
下記の設定では、WindowsMediaPlayerとRealPlayer、JPEG形式を出力するように設定してあります。
音声は省いております。
# port from your standard http web server if it is running on the same
# computer.
Port 8070 ←ffmpegを利用するポート番号
# Address on which the server is bound. Only useful if you have
# several network interfaces.
BindAddress 0.0.0.0 ←確信がないので説明省きます。デフォルトでOK
# Number of simultaneous requests that can be handled. Since FFServer
# is very fast, this limit is determined mainly by your Internet
# connection speed.
MaxClients 10 ←クライアントの最大接続台数
# This the maximum amount of kbit/sec that you are prepared to
# consume when streaming to clients
MaxBandwidth 1000 ←毎秒あたりの最大転送ビット
# Access Log file (uses standard Apache log file format)
# '-' is the standard output
CustomLog /usr/local/apache2/logs/livecam_log
↑ファイル名を指定するとアクセスログが取れます
# Suppress that if you want to launch ffserver as a daemon
NoDaemon
↑デーモンで起動しないのでNoDaemon
######################################################
# Definition of the live feeds. Each live feed contains one video
# and/or audio sequence coming from an ffmpeg encoder or another
# ffserver. This sequence may be encoded simultaneously with several
# codecs at several resolutions.
↓一時ファイルの設定 特にいじる必要なし
# You must use 'ffmpeg' to send a live feed to ffserver. In this
# example, you can type:
#
# ffmpeg http://localhost:8090/feed1.ffm
# ffserver can also do time shifting. It means that it can stream any
# previously recorded live stream. The request should contain:
# "http://xxxx?date=[YYYY-MM-DDT][[HH:]MM:]SS[.m...]".You must specify
# a path where the feed is stored on disk. You also specify the
# maximum size of the feed (100M bytes here). Default:
# File=/tmp/feed_name.ffm FileMaxSize=5M
File /tmp/feed1.ffm
FileMaxSize 1024K
# Specify launch in order to start ffmpeg automatically
# Launch
# Only allow connections from localhost to the feed
ACL allow 127.0.0.1
#######################################################
# Example streams
JPEGファイルの設定
# Single JPEG
Feed feed1.ffm
Format jpeg
VideoFrameRate 2
VideoIntraOnly
VideoSize 320x240
NoAudio
< /Stream>
WindowsMediaPlayer形式の設定(300kbit)
# ASF compatible
Feed feed1.ffm
Format asf
VideoFrameRate 15
VideoSize 320x240
VideoBitRate 300
VideoGopSize 50
NoAudio
StartSendOnKey
NoAudio
Author "KumaNeko"
Copyright "Kuma-neko ko-bo-"
Title "Kawanutsu Live"
Comment "Live Camera"
######################################
# Real with audio and video at 64 kbits
RealPlayer形式の設定 (128kbit)
Feed feed1.ffm
Format rm
#AudioBitRate 32
VideoBitRate 128
VideoFrameRate 15
VideoGopSize 25
VideoSize 320x240
NoAudio
< /Stream>
#######################################
Flashの設定 ※FlashPlayer8までは正常に動作を確認
Feed feed1.ffm
Format swf
VideoFrameRate 8
VideoSize 320x240
VideoBitRate 160
VideoIntraOnly
NoAudio
#######################################
# Special streams
# Server status
ffmepgの動作ステータス設定
この場合 http://[servername]:8090/stat.html/でストーリミングステータスが表示される
Format status
# Only allow local people to get to the status
ACL allow localhost
ACL allow 192.168.0.0 192.168.255.255
#ACL deny
#FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico
< /Stream>
# Redirect index.html to the appropriate site
URL http://ffmpeg.sourceforge.net/
< /Redire>
ffmpegを実行してみましょう。
/usr/local/bin/ffserver -f /usr/local/etc/ffserver.conf &
/usr/local/bin/ffmpeg -s 320x240 -vd /dev/video0 http:localhost:8070/feed1.ffm
※ffserverはバックグラウンドで動作させます。
【追記】最近は上記では起動できなくなりました。 -vdオプションが使えません。
/usr/local/bin/ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 /tmp/test.ffm
-f オプションはrawvideo video4linux video4linux2の3つになるのかな?
メディアプレイヤーで動作確認をしてみましょう。
メディアプレイやーの<ファイル> -
以上でLinuxでの設定は完了となります。
ffmpegを使った当HPです。【http://papanda.jp/livecam/】
【追記:おまけ】
LinuxでもUVC対応USBカメラが使えるようになりました。
#svn checkout svn://svn.berlios.de/linux-uvc/linux-uvc/trunk
#cd trunk
#make
#make install
以上でUVCドライバがインストールされます。
下記、UVC対応USBカメラを買い接続をしたところ認識されることを確認しました。
ELECOM UCAM-DLM130HWH マニュアルフォーカス
シグマ UVCA130AFWH オートフォーカス
シグマのUSBカメラですがオートフォーカス機能もバッチリ動作します。
次に出力されるストリーミングファイルをホームページで見れるようにメタファイルを作成してみましょう
- Comments (Close): 0
- TrackBacks: 0