Skip to content

Commit 397c636

Browse files
author
Alain Volmat
committed
Merge branch 'pr-tcpserversink-h264-n6' into HEAD
2 parents dab31fb + 4adeb03 commit 397c636

File tree

9 files changed

+549
-10
lines changed

9 files changed

+549
-10
lines changed

doc/build/dts/api/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ device.
466466
WS2812 GPIO driver
467467
* - zephyr,touch
468468
- touchscreen controller device node.
469+
* - zephyr,videoenc
470+
- Video encoder device, typically an H264 or MJPEG video encoder.
469471
* - mcuboot,ram-load-dev
470472
- When a Zephyr application is built to be loaded to RAM by MCUboot, with
471473
:kconfig:option:`CONFIG_MCUBOOT_BOOTLOADER_MODE_SINGLE_APP_RAM_LOAD`,
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
2+
# Copyright (c) 2025 STMicroelectronics.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
mainmenu "TCP camera streaming sample application"
6+
7+
menu "Video capture configuration"
8+
9+
config VIDEO_SOURCE_CROP_LEFT
10+
int "Crop area left value"
11+
default 0
12+
help
13+
Left value of the crop area within the video source.
14+
15+
config VIDEO_SOURCE_CROP_TOP
16+
int "Crop area top value"
17+
default 0
18+
help
19+
Top value of the crop area within the video source.
20+
21+
config VIDEO_SOURCE_CROP_WIDTH
22+
int "Crop area width value"
23+
default 0
24+
help
25+
Width value of the crop area within the video source.
26+
If set to 0, the crop is not applied.
27+
28+
config VIDEO_SOURCE_CROP_HEIGHT
29+
int "Crop area height value"
30+
default 0
31+
help
32+
Height value of the crop area within the video source.
33+
If set to 0, the crop is not applied.
34+
35+
config VIDEO_FRAME_HEIGHT
36+
int "Height of the video frame"
37+
default 0
38+
help
39+
Height of the video frame. If set to 0, the default height is used.
40+
41+
config VIDEO_FRAME_WIDTH
42+
int "Width of the video frame"
43+
default 0
44+
help
45+
Width of the video frame. If set to 0, the default width is used.
46+
47+
config VIDEO_PIXEL_FORMAT
48+
string "Pixel format of the video frame"
49+
help
50+
Pixel format of the video frame. If not set, the default pixel format is used.
51+
52+
config VIDEO_CAPTURE_N_BUFFERING
53+
int "Capture N-buffering"
54+
default 2
55+
help
56+
Framerate versus memory usage tradeoff.
57+
"2" allows to capture while sending data (optimal framerate).
58+
"1" allows to reduce memory usage but capture framerate is lower.
59+
If not set defaults to "2".
60+
61+
config VIDEO_CTRL_HFLIP
62+
bool "Mirror the video frame horizontally"
63+
help
64+
If set, mirror the video frame horizontally
65+
66+
config VIDEO_CTRL_VFLIP
67+
bool "Mirror the video frame vertically"
68+
help
69+
If set, mirror the video frame vertically
70+
71+
config VIDEO_ENCODED_PIXEL_FORMAT
72+
string "Pixel format of the encoded frame"
73+
default VIDEO_PIX_FMT_H264
74+
help
75+
Compression format used by the video encoder if enabled.
76+
If not set defaults to H264 video bitstream with startcodes.
77+
78+
endmenu
79+
80+
source "Kconfig.zephyr"

samples/drivers/video/tcpserversink/README.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This samples requires a video capture device and network support.
1818
- :zephyr:board:`mimxrt1064_evk`
1919
- `MT9M114 camera module`_
2020

21+
- :zephyr:board:`stm32n6570_dk`
22+
- :ref:`ST B-CAMS-IMX-MB1854 <st_b_cams_imx_mb1854>`
23+
2124
Wiring
2225
******
2326

@@ -26,6 +29,12 @@ J35 camera connector. A USB cable should be connected from a host to the micro
2629
USB debug connector (J41) in order to get console output via the freelink
2730
interface. Ethernet cable must be connected to RJ45 connector.
2831

32+
On :zephyr:board:`stm32n6570_dk`, the MB1854 IMX335 camera module must be plugged in
33+
the CSI-2 camera connector. A RJ45 ethernet cable must be plugged in the ethernet CN6
34+
connector. For an optimal image experience, it is advice to embed STM32 image signal
35+
processing middleware: https://github.com/stm32-hotspot/zephyr-stm32-mw-isp.
36+
37+
2938
Building and Running
3039
********************
3140

@@ -49,6 +58,15 @@ a video software pattern generator is supported by using :ref:`snippet-video-sw-
4958
:goals: build
5059
:compact:
5160

61+
For :zephyr:board:`stm32n6570_dk`, the sample can be built with the following command:
62+
63+
.. zephyr-app-commands::
64+
:zephyr-app: samples/drivers/video/tcpserversink
65+
:board: stm32n6570_dk
66+
:shield: st_b_cams_imx_mb1854
67+
:goals: build
68+
:compact:
69+
5270
Sample Output
5371
=============
5472

@@ -71,6 +89,13 @@ Example with gstreamer:
7189
7290
For video software generator, the default resolution should be width=320 and height=160.
7391

92+
When using compression support, use this GStreamer command line:
93+
94+
.. code-block:: console
95+
96+
gst-launch-1.0 tcpclientsrc host=192.0.2.1 port=5000 \
97+
! queue ! decodebin ! queue ! fpsdisplaysink sync=false
98+
7499
References
75100
**********
76101

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Video buffer pool
2+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=10000000
3+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=10
4+
5+
# Camera interface
6+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pRAA"
7+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=2592
8+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=1944
9+
CONFIG_FPU=y
10+
11+
# Capture
12+
CONFIG_VIDEO_FRAME_WIDTH=1920
13+
CONFIG_VIDEO_FRAME_HEIGHT=1080
14+
CONFIG_VIDEO_PIXEL_FORMAT="NV12"
15+
CONFIG_VIDEO_CAPTURE_N_BUFFERING=2
16+
17+
# Video encoder
18+
CONFIG_MAIN_STACK_SIZE=4096
19+
CONFIG_VIDEO_ENCODED_PIXEL_FORMAT="H264"
20+
21+
# Network buffers
22+
CONFIG_NET_BUF_RX_COUNT=4
23+
CONFIG_NET_BUF_TX_COUNT=8
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Video buffer pool
2+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=10000000
3+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=10
4+
5+
# Camera interface
6+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pRAA"
7+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=2592
8+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=1944
9+
CONFIG_FPU=y
10+
11+
# Capture
12+
CONFIG_VIDEO_FRAME_WIDTH=1920
13+
CONFIG_VIDEO_FRAME_HEIGHT=1080
14+
CONFIG_VIDEO_PIXEL_FORMAT="NV12"
15+
CONFIG_VIDEO_CAPTURE_N_BUFFERING=2
16+
17+
# Video encoder
18+
CONFIG_MAIN_STACK_SIZE=4096
19+
CONFIG_VIDEO_ENCODED_PIXEL_FORMAT="H264"
20+
21+
# Network buffers
22+
CONFIG_NET_BUF_RX_COUNT=4
23+
CONFIG_NET_BUF_TX_COUNT=8
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 STMicroelectronics.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,videoenc = &venc;
10+
};
11+
};
12+
13+
&venc {
14+
status = "okay";
15+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Video buffer pool
2+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=10000000
3+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=10
4+
5+
# Camera interface
6+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="pRAA"
7+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=2592
8+
CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=1944
9+
CONFIG_FPU=y
10+
11+
# Capture
12+
CONFIG_VIDEO_FRAME_WIDTH=1920
13+
CONFIG_VIDEO_FRAME_HEIGHT=1080
14+
CONFIG_VIDEO_PIXEL_FORMAT="NV12"
15+
CONFIG_VIDEO_CAPTURE_N_BUFFERING=2
16+
17+
# Video encoder
18+
CONFIG_MAIN_STACK_SIZE=4096
19+
CONFIG_VIDEO_ENCODED_PIXEL_FORMAT="H264"
20+
21+
# Network buffers
22+
CONFIG_NET_BUF_RX_COUNT=4
23+
CONFIG_NET_BUF_TX_COUNT=8
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (c) 2025 STMicroelectronics.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
chosen {
9+
zephyr,videoenc = &venc;
10+
};
11+
};
12+
13+
&venc {
14+
status = "okay";
15+
};

0 commit comments

Comments
 (0)