At first, I thought that SPI devices were the same as Raspberry Pi, so I planned to test the SPI bus devices. However, I was very depressed after working all day and still couldn't figure out a clue. When I went out and saw the apricot trees in full bloom in the community, I felt very happy! So I tested the camera first.
This test uses:
Logitech C270 HD USB webcam, which has built-in H.264 encoding.
Install the camera
This camera does not require any drivers, just plug it into the USB port and it will work.
Click "Camera preview" and the video image will appear on the screen. What impressed me was that the video was very smooth. It was basically the same as that of a PC. It should be noted that it was similar, but there was still a little bit of tailing. But it looked very good.
From the documentation, we know that the video system uses V4l2-ctl, which is the configuration tool of video4linux (v4l). I used ffmpeg before, but I am not very familiar with this tool. It is impossible to capture and store videos using V4l2-ctl alone. It needs to be used together with gst-launch-1.0. gst-launch-1.0 is a stream processing tool that can store stream data and output it to the network.
View device information
V4l2-ctl --info
Store the code stream
v4l2-ctl --set-parm=30;v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --stream-mmap --stream-count=-1 --stream-to=- 2>/dev/null | gst-play-1.0 "fd://0"
This command consists of four sections:
v4l2-ctl --set-parm=30;
Set the number of video capture frames to 30
v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --stream-mmap --stream-count=-1 --stream-to=- 2
Set the video format and output to the system pipeline
>/dev/null
redirected to the /dev/null file
gst-play-1.0 "fd://0"
uses gst-play-1.0 to receive data.
Output the code stream to the network
v4l2-ctl --set-parm=30;v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --stream-mmap --stream-count=-1 --stream-to=- 2>/dev/null | gst-launch-1.0 fdsrc ! jpegparse ! rtpjpegpay ! udpsink host=192.168.0.103 port=5000
Receive code stream
gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, encoding-name=JPEG ! rtpjpegdepay ! jpegparse ! decodebin ! autovideosink The
gst-launch-1.0 tool can also use the upd protocol code stream. Of course, you also need to use gst-launch-1.0 to receive the code stream.
References:
https://wiki.st.com/stm32mpu/wiki/Weston_keyboard_shortcuts#Capturing_a_screenshot
https://wiki.st.com/stm32mpu/wiki/V4l2-ctl
This content is originally created by bigbat , a user of EEWORLD forum . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source