假如和我一樣買的是Raspberry Pi Camera 或想嘗試安裝 MJPG Stream Server,可參考下列步驟:
- 安裝Raspberry Pi Camera 硬體
- 安裝必要的套件套件並安裝 MJPG Stream
pi@raspberrypi ~ $ sudo apt-get install subversion libjpeg8-dev imagemagick libv4l-dev
pi@raspberrypi ~ $ svn co https://svn.code.sf.net/p/mjpg-streamer/code/
pi@raspberrypi ~ $ cd mjpg-streamer/mjpg-streamer
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
啟動MJPG Stream Server
pi@raspberrypi ~ $ cd mjpg-streamer/mjpg-streamer
pi@raspberrypi ~ $ ./mjpg_streamer -i "./input_uvc.so -r 320x240 -f 1" -o "./output_http.so -w ./www"
在同一個 lan 的電腦打開瀏覽器輸入你的 ip:8080 (i.e.
http://192.168.1.10:8080/?action=snapshot
)
惡夢發生之訊息 |
- 解決惡夢─安裝非官方的 V4L driver
/dev/video0
可依下列步驟執行
wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc
打開
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main/etc/apt/source.list,並新增下列資訊(注意修改權限)
sudo apt-get update
及sudo apt-get install uv4l uv4l-raspicam
重開機
關閉 uv4l 的程序, 並更新
sudo pkill uv4l sudo apt-get update (非必要, 建議執行) sudo apt-get install uv4l-uvc sudo apt-get install uv4l-xscreen sudo apt-get install uv4l-mjpegstream
重開機, 再啟動./mjpg_streamer -i "./input_uvc.so -r 320x240 -f 1" -o "./output_http.so -w ./www"- 發生第二個噩夢
/dev/video0 does not support streaming i/o,
-
因為之後都要靠 uv4l 的 library 驅動所以我們要稍微調整指令
pi@raspberrypi ~ $ cd mjpg-streamer/mjpg-streamer
LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www" 如果不行請試試
uv4l --driver raspicam --auto-video_nr --extension-presence=1
啟動後,假設
Raspberry PI 的 IP 為 192.168.1.1我們可以透過瀏覽器觀看我們影像
http://192.168.1.1:8080/,如有支援Motion JPEG Video (MJPG) 編碼的播放器來看,我們可以KEY打http://192.168.1.1:8080/?action=stream觀看
影像呈現成果 |
- 在
/home/pi/.bashrc
最下面加上 :export MJPG_STREAMER_PATH=/home/pi/mjpg-streamer/mjpg-streamer
alias run-mjpg='LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so
${MJPG_STREAMER_PATH}/mjpg_streamer -i "${MJPG_STREAMER_PATH}/input_uvc.so"
-o "${MJPG_STREAMER_PATH}/output_http.so -w ${MJPG_STREAMER_PATH}/www"'
- 存檔後重新讀取 .bashrc
pi@raspberrypi ~ $
source .bashrc
- 執行簡短指令
run-mjpg
pi@raspberrypi ~ $
run-mjpg
參考資料
- http://jex.logdown.com/posts/176969-raspberry-pi-camera-mjpg-streamer-server
- http://gsyan888.blogspot.tw/2013/04/raspberry-pi-webcam-mjpg-streamer.html
- http://jacobsalmela.com/raspberry-pi-webcam-using-mjpg-streamer-over-internet/
- http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14
- http://www2.nsysu.edu.tw/csmlab/unix/vi_command.htm
- http://blogger.gtwang.org/2015/01/raspberry-pi-usb-webcam.html
1 則留言:
感谢!安装你的教程成功了。
張貼留言