Raspberry pie on the MJPG-streamer installation process

MJPG-streamer是一个优秀的开源project,它可以通过HTTP的方式访问linux上面的兼容摄像头,从而做到远程视频传输的效果。最近导师的一个project和远程视频传输有关,于是笔者在树莓派上面搭建视频传输环境的时候直接选择了MJPG-streamer。现在将整个搭建的过程贴出来,供大家参考。

1. Build environment and hardware equipment

Raspberry Pi B+, Raspberry Pi native operating system (official website can be downloaded), Raspberry Pi dedicated camera Raspberry Pi Camera. In fact, the USB camera that can be easily bought on the market is more convenient now, but the Raspberry Pi Camera is only used on the hand, and it will be used, and the Raspberry Pi Camera has several installation steps than the USB camera due to the driver problem.

2.Enable Raspberry Pi Camera

After the Raspberry Pi Camera is plugged into the correct position (note that it is not plugged in), the power is turned on. After entering the Raspberry Pi with putty, enable the camera (execute once, no need to do it every time):

1

sudo raspi-config

After entering, the camera is enabled and then restarted:

1

sudo reboot

3. Install the necessary libraries

Command the line directly to the following command:

1

2

3

4

5

6

7

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

sudo apt-get install cmake

sudo apt-get install git

4.git open source project to local, compile

1

2

3

4

sudo git clone https://github.com/jacksonliam/mjpg-streamer.git

cd mjpg-streamer/mjpg-streamer-experimental

make all

sudo make install

If it is a normal USB camera, this time should be available, type in the command line:

1

./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"

If it is a Raspberry Pi Camera, it will report an error. This is because the V4L driver does not support the raspberry pi camera, so the initialization fails.

5. Solve the problem that V4L driver does not support

Install the necessary libraries:

1

sudo wget http://www.linux-projects.org/listing/uv4l_repo/lrkey.asc && sudo apt-key add ./lrkey.asc

Modify the sources list

1

sudo nano /etc/apt/sources.list

Add a line at the end:

1

2

3

4

5

6

deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/ wheezy main

Continue to install:

sudo apt-get update

sudo apt-get install uv4l uv4l-raspicam

sudo reboot

After rebooting:

1

2

3

4

5

6

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 reboot

After restarting again:

1

2

sudo modprobe bcm2835-v4l2

./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -n -y -f 25 -r 640x480" -o "./output_http.so -n -w /usr/local/www"

Then open your browser and type: Http://raspberry-ip-address:8080/?action=stream You should be able to see the dynamic video captured by the Raspberry Pi Camera, with a delay of no more than 0.8 seconds.

note:

1

sudo modprobe bcm2835-v4l2

This command is executed every time before you can open the camera. You can set it to boot and execute it.