原文:http://www.jianshu.com/p/2304006c2f78
根据最新的git项目更新和自己的实践,主要把ffmpeg推流的命令做了修改。
安装 Nodejs/ffmpeg
# 1. install nodejs
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
node -v
# 2. install ffmpeg
## libx264 support
git clone git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
make
sudo make install
## ffmpeg
git clone git://git.ffmpeg.org/ffmpeg
cd ffmpeg
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
make # 这一步可能相当相当漫长,在我这里跑了有一个多小时
sudo make install
Webcam
创建 Node server 监听 http://127.0.0.1:8081:
git clone https://github.com/phoboslab/jsmpeg.git webcam
cd webcam && node websocket-relay.js yourpassword
# Listening for MPEG Stream on http://127.0.0.1:8081/<secret>/<width>/<height>
# Awaiting WebSocket connections on ws://127.0.0.1:8082/
通过 ffmpeg 转换视频格式:
raspivid -t 0 -w 320 -h 240 -o - | ffmpeg -i - -f mpegts -codec:v mpeg1video -s 320x240 -b:v 1000k -bf 0 http://127.0.0.1:8081/yourpassword
然后打开stream-example.html就可以看到实时监控画面了,如果是远程调试需要稍作更改:
# edit stream-example.html
var client = new WebSocket( 'ws://RASPI_LOCAL_IP:8082/' );
var player = new jsmpeg(client, {canvas:canvas});
# @/path/to/webcam
python -m SimpleHTTPServer 8080
# in your browser
http://RASPI_LOCAL_IP:8080
作者:Yusheng
链接:http://www.jianshu.com/p/2304006c2f78
來源:简书