[夏肇毅知識運算網 Mark Hsia's Knowledge Computing Web]
樹莓派Raspberry Pi可以變成一個即時攝影串流伺服器. 我們可以選擇UV4L 或 MJPG-streamer.
裝好攝影頭及軟體後它就變成一部活動監視器. 透過瀏覽器我們可以隨時監看畫面.
A Raspberry Pi with a camera can become a real time stream sever. We can select either
UV4L or mjpg-streamer to transmit its streaming data.
UV4L(User space Video4Linux collection) includes a full-featured Streaming Server component providing a set of solutions for live audio & video streaming, casting/mirroring and conferencing over the web.
On the other hand, the MJPG-streamer takes JPGs from Linux-UVC compatible webcams, file system or other input plugins and streams them as M-JPEG via HTTP to web browsers, VLC and other software.
We can install both on the Raspberry Pi.
First, we connect the Camera bus to the Raspberry Pi board, and the start the raspi-config:
sudo raspi-config
Select item 6 to enable the camera:
6 Enable Camera .......
Reboot and run tests:
raspistill -o cam.jpg
raspivid -o vid.h264
The image/video window will be shown on the console.
Install MJPEG Stream components:
sudo apt-get update
sudo apt-get install subversion
sudo apt-get install libjpeg8-dev
sudo apt-get install imagemagick
sudo apt-get install libv4l-dev
Get mjpg-streamer from svn:
svn co https://svn.code.sf.net/p/mjpg-streamer/code/
cd code/mjpg-streamer
make
sudo make install
wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc
sudo nano /etc/apt/sources.list
Add this line to the file and exit:
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main
sudo apt-get update
sudo apt-get install uv4l uv4l-raspicam
For autostart service:
sudo apt-get install uv4l-raspicam-extras
sudo reboot
Install 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
sudo apt-get install uv4l-server
sudo reboot
The WebRTC extension for the Streaming Server is also available:
sudo apt-get install uv4l-webrtc
uv4l --auto-video_nr --driver raspicam --encoding mjpeg --server-option '--port=9000' or uv4l --auto-video_nr --driver raspicam --encoding mjpeg --server-option '--port=9000' --driver raspicam --rotation 180 --width 352 --height 288
Use Browser to link to the uv4l server:
http://192.168.0.x:9000
sudo modprobe bcm2835-v4l2
cd code/mjpg-streamer
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"
Use Browser to link to the mjpg-streamer:
http://192.168.0.x:8080
Reference:
https://dotblogs.com.tw/bowwowxx/2015/06/08/151511