Yocto i.mx6 (TQIMX6) (04): Use Mjpg-streamer to do a webcam Server

Source: Internet
Author: User
Tags svn imx6 yocto
Compilation of Libjpeg

After downloading, you can specify the configure directly. or use Yocto to compile and refer to my other blog posts related to Yocto. Compilation of Mjpg-server

Mjpg-streamer is already very old, and the download file in SourceForge, the default is Deb format, so need to find the corresponding source code

Download Address: http://sourceforge.net/projects/mjpg-streamer/files/mjpg-streamer/Sourcecode/



compiling

After downloading, unzip and change the CC in all makefile to accept the preset format, which is about: [plain] view plain copy cc = GCC
Change into:

[plain] view plain copy CC? = gcc
To prevent less modification, you can also use grep to see what files are:

[plain] view plain copy grep ' CC = gcc '--color
The results are as follows:



For modifying makefile, you can use SED with the awk combination to complete the following commands:

[plain] view plain copy sed ' s/= gcc/?= gcc/g ' i ' Find-name makefile-print0 | xargs-0 grep ' CC = gcc '--color | Awk-f ': ' {print $} '
Then use grep to see if the file has been changed. Place the Mjpg-streamer library output file on target Lib Library so file

Simply use the SCP or some other way to put it in target, here's an example:[Plain] View Plain Copy $SCP  hexiongjun@192.168.2.100scp hexiongjun@192.168.2.100:/media/work/imx6/videocap/ mjpg-streamer-code-182/mjpg-streamer/*.so  /usr/lib/   hexiongjun@192.168.2.100 ' s  password: streamer/*.so .  ' 68.2.100:/media/work/imx6/v   input_file.so                                   100%   29KB   28.8KB/s   00:00       input_testpicture.so                            100%  177KB 177.2KB/s   00:00        input_uvc.so                                   100%    92KB  92.1KB/s   00:00       Output_ file.so                                 100%    42KB  41.6KB/s   00:00       output_http.so                                  100%   75KB   74.7KB/s   00:00       output_udp.so                                   100%   32kb  32.3kb/s    00:00   Mjpg-streamer executable fileThen place the Mjpg-streamer executable into the path of the/usr/bin or other path variable:[Plain]View plain copy $scp HEXIONGJUN@192.168.2.100SCP hexiongjun@192.168.2.100:/media/work/imx6/videocap/ mjpg-streamer-code-182/mjpg-streamer/mjpg-streamer/usr/bin/
instructions for the use of Mjpg-streamer

Take a look at the Help documentation before you use it:

[Plain] View Plain Copy root@imx6qsabresd:/usr/bin# mjpg_streamer -h  ------------------------------- ----------------------------------------   usage: mjpg_streamer     -i |  --input  "<input-plugin.so> [parameters]"      -o | --output   "<output-plugin.so> [parameters]"     [-h | --help .:  display this help    [-v | --version ].....: display  version information    [-b | --background]...: fork to the  background, daemon mode  ----------------------------------------------------------------- ------   example  #1:    To open an UVC webcam  "/dev/ Video1 " and stream it via HTTP:     mjpg_streamer -i " Input_uvc.sO -d /dev/video1 " -o " output_http.so "  ----------------------------------------- ------------------------------   example  #2:   &NBSP;TO&NBSP;OPEN&NBSP;AN&NBSP;UVC  webcam and stream via HTTP port 8090:     mjpg_streamer  -i  "input_uvc.so"  -o  "output_http.so -p 8090"   ---------------------- -------------------------------------------------   example  #3:    to get  help for a certain input plugin:     mjpg_streamer -i   "Input_uvc.so --help"   ------------------------------------------------------------------ -----   in case the modules  (=plugins)  can not be found:     * Set the default search path for the modules  with:      export LD_LIBRARY_PATH=/path/to/plugins,    * or put the  plugins into the  "/lib/"  or  "/usr/lib"  folder,    * or  instead of just providing the plugin file name, use a  complete      path and filename:      mjpg_streamer  -i  "/path/to/modules/input_uvc.so"   ----------------------------------------------------- ------------------  

summed up is:

[plain] view plain copy mjpg-streamer input_plugin_lib input_plugin_option output_plugin_lib output_plugin_ Option

You can see that there are three input plugin:

[plain] view plain copy root@imx6qsabresd:/usr/bin# ls/usr/lib/input_*-l-rwxr-xr-x 1 root 29506 Dec 21 03:51/usr/lib/input_file.so-rwxr-xr-x 1 root 181443 Dec 03:51/usr/lib/input_testpicture.so-rwxr-xr-x 1 ro OT root 94272 Dec 03:51/usr/lib/input_uvc.so

Its output plugin also has three:

[plain] view plain copy root@imx6qsabresd:/usr/bin# ls/usr/lib/output_*-l-rwxr-xr-x 1 root 42604 Dec 21 03:51/usr/lib/output_file.so-rwxr-xr-x 1 root 76517 Dec 03:51/usr/lib/output_http.so-rwxr-xr-x 1 root Roo T 33119 Dec 03:51/usr/lib/output_udp.so

As a result, the default combination can be 9 cases.

Input can be file, test virtual video and UVC camera; output can be file/http and UDP. Each has its own characteristics, the output of a total of two categories: streaming media recorded as a file to use the test

We can use the actual video device to direct capture, so if there is a problem, then we will need to determine whether we are porting the mjpg-streamer problem or the problem of our equipment, so we decouple it, do a simulation of the video to test, Make sure the porting program is OK and continue using the actual device.

As mentioned earlier, there are three input plugin, one of which is input_testpicture.so, which is actually a virtual test, so we use the following command on target to test. Create a WWW output directory This is used in the HTTP output: [plain] view plain copy mkdir/var/www

Start Streamer

For the use of Mjpg-streamer, you can view the start.sh in source code:

[plain] view plain copy mjpg_streamer-i "Input_testpicture.so-r 320*240"-O "output_http.so-w/var/www"
The output of log is:

[plain] view plain copy i:delay ...: 1000 i:resolution ...: 640x480 o:www-folder-path ...:/va-------- R/WWW/O: HTTP TCP Port ...: 8080 O:username:password.: Disabled O:commands ....:-Enabled

As you can see, the resolution we set (resolution) is not valid, it uses 640x480 by default, and other formats are not supported.

There is also a default HTTP TCP port of 8080.


View Video Output

Use the method to refer to the Readme in source code

Here, using the browser, open Target's web site, assuming that our target targets have IP 192.168.2.120, then enter in the browser:

[plain] view plain copy Http://192.168.2.120:8080/?action=stream

You will find that the prompt cannot find the file:


But it's OK to open the following page:

[plain] view plain copy Http://192.168.2.120:8080/?action=snapshot


Then we keep refreshing the page and we can see the frame changing in the browser.

We can also use video players such as VLC or mplayer to view the contents of the streamer, for example, in VLC, which has the following effect:


Based on these two Tests, we can determine if the porting program is not a problem.



acquisition of YUV camera

Insert the USB camera, and the kernel will have similar output as follows:

[plain] view plain copy [0.000000] uvcvideo:found UVC 1.00 device USB2.0 (Camera) [0.000000] Revserved_memory_account:viv_gpu Registerd

And then make sure that the device node is generated/dev/videox


The default is based on previous experience, we test the same, but we specify the device with the other input plugin, as our UVC camera, the results are as follows

[plain] view plain copy output_http.so "sd:/usr/bin# mjpg_streamer-i" input_uvc.so-d/dev/video0 "-o" O mjpg  Streamer VERSION:SVN rev:exported i:using v4l2 device.:/dev/video0 i:desired resolution:640 x i:frames Per Second.: 5 I:format ...: MJPEG unable to set format:1196444237 res:640x480 Init V4L2 failed!! Exit Fatal I:init_videoin failed root@imx6qsabresd:/usr/bin#

Found that we had failed, and one of the details was

[plain] view plain copy I:format .....: MJPEG

Description Streamer expects to configure our camera for MJPEG output, but we do not support the camera, so prompt:

Init V4L2 failed!! Exit fatal

For this, we need to add the-y parameter, specify the camera output frame format is YUV:

[plain] view plain copy mjpg_streamer-i "input_uvc.so-d/dev/video0-f 30-r 320*240-y"-O "output_http.so-w /var/www "

Enter the following:

[Plain] View Plain Copy mjpg streamer version: svn rev: exported    i: Using  V4L2 device.: /dev/video0    i: desired resolution: 320 x  240    i: Frames Per Second.: 30    i: format ............: yuv    i: JPEG Quality......: 80   adding  control for pan  (relative)    control exists: file exists   adding control for tilt  (relative)    control exists: file exists    adding control for pan reset   control exists: file  exists   adding control for tilt reset   Control exists: File  exists   adding control for pan/tilt reset   controuvcvideo:  failed to query  (get_def)  UVC control 11 on unit 3: -32  (exp. 1).    l exists: file exists   adding control for focus  ( Absolute)    control exists: file exists   mapping control for  pan  (relative)    uvcioc_ctrl_map - error: no such file or  directory   mapping control for tilt  (relative)    uvcioc_ctrl_map -  Error: No such file or directory   mapping control for  pan reset   uvcioc_ctrl_map - error: no&

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.