How to Implement Remote Video Surveillance on Forlinx Embedded OKA40i-C EVK?
With the continuous development of IoT technology, remote monitoring has become a necessary function in more and more scenarios. And in realizing remote monitoring, the transmission of video streams is particularly important. This article will introduce how to use the open source software MJPG-Streamer and Libjpeg library to implement remote video monitoring on the Forlinx Embedded OKA40i-C Evaluation Kit.
01 What is the open source software MJPG-Streamer?
The principle of MJPG-Streamer is to send the image captured by the USB camera in JPEG format and then continuously update the image to form a video stream.
It is outstanding in compatibility with browsers, allowing easy display in browsers without worrying about whether the browser supports Flash or streaming protocols;
As there is no correlation between the front and back frames with JPEG, if packet loss occurs, it only affects the current frame but not like the H.264 with mosaic images that may be continuous for some time.
JPEG streams are less efficient in compression and waste more bandwidth than H.264.
02 How to compile the Libjpeg library?
MJPG-Streamer will use libjpeg, so first, we need to compile libjpeg. Firstly visit http://www.ijg.org/ to download the source code. Now we are using the latest version 9e.
Extract the source code to the jpeg-9e directory, and execute the configure command under this command to configure:
The host specifies the compiler used and prefix specifies the directory where the compiled files will be installed.
Then execute the following command:
1 make 2 make install
When the command is executed, four directories will be created in the directory specified by the prefix. The include directory contains the required header files, while the lib directory contains the library files used later.
After compiling, we need to copy libjpeg.so.9.5.0 to the /usr/lib directory of the development board and create a soft link to that file, libjpeg.so.9.
In addition, the EVK originally came with libjpeg.so.8.0.2. If not willing to update the version, we can also download the historical version corresponding to the board at http://www.ijg.org/files/.
03 Complilation of MJPG-Streamer
MJPG-Streamer is available in two main versions (link recommended to open on PC):
It is the original version( no updating anymore).
It is the subsequent updated version.
To implement it on Forlinx Embedded OKA40i-C, we can only use SourceForge. Although the GitHub version is newer, it requires the kernel version, at least 3.18 or above.
The kernel version provided with the OKA40i-C EVK is 3.10, which cannot correctly handle some V4L2 messages of the new versions. In addition, the GitHub version is compiled with CMake, and the compilation method described later is not applicable.
Visit “Download Snapshot” (on the top right) to download the latest mjpg-streamer-code-182. Then we can see two mjpg-streamer directories. Generally, mjpg-streamer-experimental is used more, which supports a bit more features.
Before compiling, we need to modify the makefile file in the plugins/input_uvc directory by adding the following two lines to it:
The purpose of these two lines is to help us to find the libjpeg library(we generated earlier when compiling). If modifying the plug-in settings of MJPG-Streamer, we can also modify the makefile in the mjpg-streamer-experimental directory.
No other plugins were used in this test, so the default configuration was used.Then execute the following command at the command line to compile it.
1 make CC=arm-linux-gnueabihf-gcc
After successful compilation, copy mjpg_streamer and several so files to the EVK and set the permissions correctly, then it is ready to run.
04 Test Results
The input_testpicture plugin comes with a default picture that we can use to test the function of the MJPG-Streamer even if we don't have a camera on hand.
Enter the following command on the EVK side:
1 ./mjpg_streamer -i "input_testpicture.so"
If using the USB camera, we need to use the input_uvc.so plug in and enter the command on the EVK side. The result is shown as follows:
1 ./mjpg_streamer -i "input_uvc.so -r 800x600" -o "output_http.so"