Difference between revisions of "Template:FriendlyCoreAllwinner-DVPCam"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
Line 6: Line 6:
 
$ ./start.sh
 
$ ./start.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
请自行修改start.sh, 确保使用正确的/dev/videoX节点, 下列命令可以用来确定摄像头的video节点:
+
You need to change the start.sh script and make sure it uses a correct /dev/videoX node. You can check your camera's node by running the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ apt-get install v4l-utils
 
$ apt-get install v4l-utils
Line 17: Line 17:
 
...
 
...
 
</syntaxhighlight>
 
</syntaxhighlight>
上述信息表示/dev/video0是CAM500B的设备节点。The mjpg-streamer application is an open source video steam server. After it is successfully started the following messages will be popped up:
+
The above messages indicate that "/dev/video0" is CAM500B's device node.The mjpg-streamer application is an open source video steam server. After it is successfully started the following messages will be popped up:
 
<syntaxhighlight lang="bash">  
 
<syntaxhighlight lang="bash">  
 
$ ./start.sh
 
$ ./start.sh
Line 33: Line 33:
 
In our case the board's IP address was 192.168.1.230. We typed 192.168.1.230:8080 in a browser and were able to view the images taken from the camera's. Here is what you would expect to observe:<br>
 
In our case the board's IP address was 192.168.1.230. We typed 192.168.1.230:8080 in a browser and were able to view the images taken from the camera's. Here is what you would expect to observe:<br>
 
[[File:mjpg-streamer-cam500a.png|frameless|400px|mjpg-streamer-cam500a]] <br>
 
[[File:mjpg-streamer-cam500a.png|frameless|400px|mjpg-streamer-cam500a]] <br>
mjpg-streamer是用libjpeg对摄像头数据进行软编码,Linux-4.x内核的ROM目前并不支持视频硬编码, 但是如果使用Linux-3.x内核的ROM的话, 则可以使用ffmpeg对摄像头数据进行硬编码,这样能大大降低CPU的占用率并提高编码速度:
+
The mjpg-streamer utility uses libjpeg to software-encode steam data. The Linux-4.x based ROM currently doesn't support hardware-encoding. If you use a Linux-3.x based ROM you can use the ffmpeg utility to hardware-encode stream data and this can greatly release CPU's resources and speed up encoding:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
$ ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 \
 
$ ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 \

Revision as of 06:32, 16 April 2018

The CAM500B camera module is a 5M-pixel camera with DVP interface. For more tech details about it you can refer to Matrix - CAM500B.
connect your H3 board to a CAM500B. Then boot OS, connect your board to a network, log into the board as root and run "mjpg-streamer":

$ cd /root/mjpg-streamer
$ make
$ ./start.sh

You need to change the start.sh script and make sure it uses a correct /dev/videoX node. You can check your camera's node by running the following commands:

$ apt-get install v4l-utils
$ v4l2-ctl -d /dev/video0 -D
Driver Info (not using libv4l2):
        Driver name   : sun6i-video
        Card type     : sun6i-csi
        Bus info      : platform:camera
        Driver version: 4.16.0
	...

The above messages indicate that "/dev/video0" is CAM500B's device node.The mjpg-streamer application is an open source video steam server. After it is successfully started the following messages will be popped up:

 
$ ./start.sh
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 1280 x 720
 i: Frames Per Second.: 30
 i: Format............: YUV
 i: JPEG Quality......: 90
 o: www-folder-path...: ./www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled

In our case the board's IP address was 192.168.1.230. We typed 192.168.1.230:8080 in a browser and were able to view the images taken from the camera's. Here is what you would expect to observe:
mjpg-streamer-cam500a
The mjpg-streamer utility uses libjpeg to software-encode steam data. The Linux-4.x based ROM currently doesn't support hardware-encoding. If you use a Linux-3.x based ROM you can use the ffmpeg utility to hardware-encode stream data and this can greatly release CPU's resources and speed up encoding:

$ ffmpeg -t 30 -f v4l2 -channel 0 -video_size 1280x720 -i /dev/video0 -pix_fmt nv12 -r 30 \
        -b:v 64k -c:v cedrus264 test.mp4

By default it records a 30-second video. Typing "q" stops video recording. After recording is stopped a test.mp4 file will be generated.