Registered User |
Registered User (DV6.0 changes) |
||
(19 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<noinclude>{{ApplicableFor | <noinclude> | ||
{{ApplicableFor | |||
|MPUs list=STM32MP13x, STM32MP15x | |MPUs list=STM32MP13x, STM32MP15x | ||
|MPUs checklist=STM32MP13x,STM32MP15x | |MPUs checklist=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | ||
}}</noinclude> | }} | ||
</noinclude> | |||
== Overview == | == Overview == | ||
This article | This article explains how to stream camera content over network thanks to [[GStreamer overview|GStreamer]] application on top of [[V4L2_camera_overview | V4L2 Linux<sup>®</sup> kernel framework]]. | ||
Capturing compressed JPEG pictures is an efficient way to send camera images to any local or remote player. JPEG pictures require a limited bandwidth while being fully interoperable. | |||
{{Info | This article focus on camera sensors that can directly output JPEG content, if it is not the case refer to [[How to stream RAW camera over network]].}} | |||
Find below some examples of command lines allowing to capture a continuous JPEG stream while playing it using various multimedia players, either local or remote. | Find below some examples of command lines allowing to capture a continuous JPEG stream while playing it using various multimedia players, either local or remote. | ||
Line 13: | Line 18: | ||
Here is an example of a local preview involving [[V4l2-ctl]] for JPEG pictures capture and [[Gst-play|gst-play]] GStreamer player for JPEG decoding and display. JPEG pictures are sent over a standard Linux pipe. | Here is an example of a local preview involving [[V4l2-ctl]] for JPEG pictures capture and [[Gst-play|gst-play]] GStreamer player for JPEG decoding and display. JPEG pictures are sent over a standard Linux pipe. | ||
{{ | {{WestonLaunch}} | ||
{| class="st-table mw-collapsible mw-collapsed" | {| class="st-table mw-collapsible mw-collapsed" | ||
| For {{MicroprocessorDevice | device=135}}, | | For {{MicroprocessorDevice | device=135}}, set up the camera subsystem first: | ||
|- | |- | ||
| | | | ||
{{Board$}} media-ctl -d /dev/media0 --set-v4l2 "'ov5640 1-003c':0[fmt:JPEG_1X8/640x480@1/30 field:none]" | {{Board$}} | ||
media-ctl -d /dev/media0 --set-v4l2 "' | media-ctl -d /dev/media0 --set-v4l2 "'ov5640 1-003c':0[fmt:JPEG_1X8/640x480@1/30 field:none]" | ||
media-ctl -d /dev/media0 --set-v4l2 "' | media-ctl -d /dev/media0 --set-v4l2 "'st-mipid02 1-0014':2[fmt:JPEG_1X8/640x480]" | ||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[fmt:JPEG_1X8/640x480]" | media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_input':1[fmt:JPEG_1X8/640x480]" | ||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[fmt:JPEG_1X8/640x480]" | |||
|} | |} | ||
Capture the JPEG pictures then decode and display them: | |||
{{Board$}}v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --set-parm=30 --stream-mmap --stream-count=-1 {{highlight|'''--stream-to{{=}}-'''}} {{HighlightParam|2>/dev/null}} {{highlight|'''<nowiki>|</nowiki>'''}} gst-play-1.0 {{highlight|'''"fd://0"'''}} | |||
Capture JPEG pictures then decode | |||
{{Board$}} | |||
{{highlight|'''--stream-to{{=}}-'''}} tells [[V4l2-ctl]] to output binary captured content to standard output, which is then sent to pipe {{highlight|'''<nowiki>|</nowiki>'''}}. | {{highlight|'''--stream-to{{=}}-'''}} tells [[V4l2-ctl]] to output binary captured content to standard output, which is then sent to pipe {{highlight|'''<nowiki>|</nowiki>'''}}. | ||
Line 37: | Line 39: | ||
Note the {{HighlightParam|2>/dev/null}} right after the [[V4l2-ctl]] command to remove the logs from console output. | Note the {{HighlightParam|2>/dev/null}} right after the [[V4l2-ctl]] command to remove the logs from console output. | ||
== UDP streaming == | == UDP streaming == | ||
An internet connection is required, for example by plugging an | An internet connection is required, for example, by plugging an Ethernet cable on the: | ||
{| class="st-table" | {| class="st-table" | ||
| {{Board | type=135x-DK}} | | {{Board | type=135x-DK}} | ||
Line 53: | Line 55: | ||
|} | |} | ||
{{Info | On the STM32MP135x-DK board, the [[Camera sensors hardware components | GC2145 camera sensor]] is not capable of streaming JPEG data, hence JPEG based network streaming is not possible with this sensor. The example below is given using a CSI based OV5640 sensor, capable of JPEG output.}} | |||
{| class="st-table mw-collapsible mw-collapsed" | {| class="st-table mw-collapsible mw-collapsed" | ||
| For {{MicroprocessorDevice | device=135}}, | | For {{MicroprocessorDevice | device=135}}, set up the camera subsystem first: | ||
|- | |- | ||
| | | | ||
{{Board$}} media-ctl -d /dev/media0 --set-v4l2 "'ov5640 1-003c':0[fmt:JPEG_1X8/640x480@1/30 field:none]" | {{Board$}} | ||
media-ctl -d /dev/media0 --set-v4l2 "' | media-ctl -d /dev/media0 --set-v4l2 "'ov5640 1-003c':0[fmt:JPEG_1X8/640x480@1/30 field:none]" | ||
media-ctl -d /dev/media0 --set-v4l2 "'st-mipid02 1-0014':2[fmt:JPEG_1X8/640x480]" | |||
media-ctl -d /dev/media0 --set-v4l2 "' | media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_input':1[fmt:JPEG_1X8/640x480]" | ||
media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[ | media-ctl -d /dev/media0 --set-v4l2 "'dcmipp_dump_postproc':1[fmt:JPEG_1X8/640x480]" | ||
|} | |} | ||
Get the IP address {{highlight|'''aa.bb.cc.dd'''}} of the host PC using [[Ifconfig|ifconfig]] command: | Get the IP address{{highlight|'''aa.bb.cc.dd'''}} of the host PC using the [[Ifconfig|ifconfig]] command: | ||
{{PC$}} ifconfig | grep "inet | {{PC$}}ifconfig | grep "inet" | ||
inet addr:{{highlight|'''aa.bb.cc.dd'''}} Bcast:10.201.23.255 Mask:255.255.252.0 | inet addr:{{highlight|'''aa.bb.cc.dd'''}} Bcast:10.201.23.255 Mask:255.255.252.0 | ||
inet addr:127.0.0.1 Mask:255.0.0.0 | inet addr:127.0.0.1 Mask:255.0.0.0 | ||
Then fill the {{HighlightParam|'''host{{=}}'''}} udpsink property with this IP address on the remote side: | Then fill the {{HighlightParam|'''host{{=}}'''}} udpsink property with this IP address on the remote side: | ||
{{Board$}} | {{Board$}}v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --set-parm=30 --stream-mmap --stream-count=-1 --stream-to=- 2>/dev/null | gst-launch-1.0 fdsrc ! jpegparse ! rtpjpegpay ! udpsink {{HighlightParam|'''host{{=}}'''}}{{highlight|'''aa.bb.cc.dd'''}} port=5000 | ||
Then play the UDP stream on host PC: | Then play the UDP stream on the host PC: | ||
{{PC$}} gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, encoding-name=JPEG ! rtpjpegdepay ! jpegparse ! decodebin ! videoconvert ! autovideosink | {{PC$}}gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, encoding-name=JPEG ! rtpjpegdepay ! jpegparse ! decodebin ! videoconvert ! autovideosink | ||
A new window | A new window appears on the host PC displaying the camera content. | ||
{{Info|Due to SDP protocol signaling, this solution is not fully interoperable because it needs a dedicated GStreamer command line to be played on host side}} | {{Info | Due to SDP protocol signaling, this solution is not fully interoperable because it needs a dedicated GStreamer command line to be played on the host side.}} | ||
<!-- | <!-- | ||
== RTSP streaming == | == RTSP streaming == | ||
{{Warning| | {{Warning| need to explain gst-rtsp-server-launch-1.0 (derived from GStreamer example test_launch.c of rtsp libraries) and not yet documented}} | ||
Prerequesite: | Prerequesite: | ||
* Board connected to local network | * Board connected to local network | ||
Line 88: | Line 91: | ||
* gst-rtsp-server-launch-1.0 [[GStreamer overview|GStreamer]] utility | * gst-rtsp-server-launch-1.0 [[GStreamer overview|GStreamer]] utility | ||
* Get the ip address of the board: | * Get the ip address of the board: | ||
{{Board$}} ifconfig | {{Board$}}ifconfig | ||
eth0 Link encap:Ethernet HWaddr 00:80:E1:42:42:D8 | eth0 Link encap:Ethernet HWaddr 00:80:E1:42:42:D8 | ||
Line 95: | Line 98: | ||
Capture VGA jpeg pictures and stream them over network using RTSP streaming protocol: | Capture VGA jpeg pictures and stream them over network using RTSP streaming protocol: | ||
{{Board$}} gst-rtsp-server-launch-1.0 {{blue|'''10.48.1.122'''}} 8081 "/test" "( v4l2src do-timestamp=true device=/dev/video0 ! image/jpeg, width=640, height=480, framerate=(fraction)15/1 ! queue ! jpegparse ! rtpjpegpay name=pay0 pt=96 )" | {{Board$}}gst-rtsp-server-launch-1.0 {{blue|'''10.48.1.122'''}} 8081 "/test" "( v4l2src do-timestamp=true device=/dev/video0 ! image/jpeg, width=640, height=480, framerate=(fraction)15/1 ! queue ! jpegparse ! rtpjpegpay name=pay0 pt=96 )" | ||
stream ready at {{green|'''rtsp://10.48.1.122:8081/test'''}} | stream ready at {{green|'''rtsp://10.48.1.122:8081/test'''}} | ||
Line 101: | Line 104: | ||
Stream can then be played on host PC using any media player which support RTSP streaming such as [[GStreamer overview|GStreamer]] or VLC: | Stream can then be played on host PC using any media player which support RTSP streaming such as [[GStreamer overview|GStreamer]] or VLC: | ||
{{PC$}} gst-play-1.0 {{green|'''rtsp://10.48.1.122:8081/test'''}} | {{PC$}}gst-play-1.0 {{green|'''rtsp://10.48.1.122:8081/test'''}} | ||
{{PC$}} cvlc {{green|'''rtsp://10.48.1.122:8081/test'''}} | {{PC$}}cvlc {{green|'''rtsp://10.48.1.122:8081/test'''}} | ||
Stream can also be played on another target with same [[Gst-play|gst-play]] [[GStreamer overview|GStreamer]] utility: | Stream can also be played on another target with same [[Gst-play|gst-play]] [[GStreamer overview|GStreamer]] utility: | ||
{{Board$}} gst-play-1.0 {{green|'''rtsp://10.48.1.122:8081/test'''}} | {{Board$}}gst-play-1.0 {{green|'''rtsp://10.48.1.122:8081/test'''}} | ||
--> | --> | ||
<noinclude> | <noinclude> | ||
{{ArticleBasedOnModel | How to article model}} | {{ArticleBasedOnModel | How to article model}} | ||
{{PublicationRequestId | | {{PublicationRequestId | 32058| 2024-08-22 | }} | ||
[[Category:How to run use cases]] | [[Category:How to run use cases]] | ||
[[Category:V4L2]] | [[Category:V4L2]] | ||
[[Category:GStreamer]] | [[Category:GStreamer]] | ||
</noinclude> | </noinclude> |
Latest revision as of 16:48, 25 November 2024
1. Overview
This article explains how to stream camera content over network thanks to GStreamer application on top of V4L2 Linux® kernel framework.
Capturing compressed JPEG pictures is an efficient way to send camera images to any local or remote player. JPEG pictures require a limited bandwidth while being fully interoperable.
Find below some examples of command lines allowing to capture a continuous JPEG stream while playing it using various multimedia players, either local or remote.
2. Local streaming
Here is an example of a local preview involving V4l2-ctl for JPEG pictures capture and gst-play GStreamer player for JPEG decoding and display. JPEG pictures are sent over a standard Linux pipe.
ExpandFor STM32MP135 line ![]() |
Capture the JPEG pictures then decode and display them:
--stream-to=- 2>/dev/null | gst-play-1.0 "fd://0"v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --set-parm=30 --stream-mmap --stream-count=-1
--stream-to=- tells V4l2-ctl to output binary captured content to standard output, which is then sent to pipe |.
Special URI fd://0 tells gst-play GStreamer player to read data from the pipe.
Note the 2>/dev/null right after the V4l2-ctl command to remove the logs from console output.
3. UDP streaming
An internet connection is required, for example, by plugging an Ethernet cable on the:
STM32MP135x-DK Discovery kit ![]() |
CN4 Ethernet connector 1 or CN15 Ethernet connector 2 |
STM32MP157x-DKx Discovery kit ![]() |
CN8 Ethernet connector |
STM32MP157x-EV1 Evaluation board ![]() |
CN3 Ethernet connector |
ExpandFor STM32MP135 line ![]() |
Get the IP addressaa.bb.cc.dd of the host PC using the ifconfig command:
aa.bb.cc.dd Bcast:10.201.23.255 Mask:255.255.252.0 inet addr:127.0.0.1 Mask:255.0.0.0ifconfig | grep "inet" inet addr:
Then fill the host= udpsink property with this IP address on the remote side:
host=aa.bb.cc.dd port=5000v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=JPEG --set-parm=30 --stream-mmap --stream-count=-1 --stream-to=- 2>/dev/null | gst-launch-1.0 fdsrc ! jpegparse ! rtpjpegpay ! udpsink
Then play the UDP stream on the host PC:
gst-launch-1.0 udpsrc port=5000 ! application/x-rtp, encoding-name=JPEG ! rtpjpegdepay ! jpegparse ! decodebin ! videoconvert ! autovideosink
A new window appears on the host PC displaying the camera content.