Skip to content

Commit 2a9b0d5

Browse files
committed
Merge branch 'feat/update_hdmi_video_dual_task' into 'master'
feat(lcd): Added an example for displaying MP4/AVI format videos on HDMI See merge request ae_group/esp-iot-solution!1311
2 parents e74bab6 + b8d8d29 commit 2a9b0d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4565
-4
lines changed

.gitlab/ci/build.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ build_example_check_pedestrian_flow:
394394
variables:
395395
EXAMPLE_DIR: examples/check_pedestrian_flow
396396

397+
build_example_display_lcd_hdmi_video_renderer:
398+
extends:
399+
- .build_examples_template
400+
- .rules:build:example_display_lcd_hdmi_video_renderer
401+
parallel:
402+
matrix:
403+
- IMAGE: espressif/idf:release-v5.4
404+
variables:
405+
EXAMPLE_DIR: examples/display/lcd/hdmi_video_renderer
406+
397407
build_example_display_lcd_lcd_layer_blending:
398408
extends:
399409
- .build_examples_template

.gitlab/ci/rules.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,9 @@
484484
.patterns-example_common_components_camera: &patterns-example_common_components_camera
485485
- "examples/common_components/camera/**/*"
486486

487+
.patterns-example_display_lcd_hdmi_video_renderer: &patterns-example_display_lcd_hdmi_video_renderer
488+
- "examples/display/lcd/hdmi_video_renderer/**/*"
489+
487490
.patterns-example_display_lcd_lcd_layer_blending: &patterns-example_display_lcd_lcd_layer_blending
488491
- "examples/display/lcd/lcd_layer_blending/**/*"
489492

@@ -909,6 +912,12 @@
909912
- <<: *if-dev-push
910913
changes: *patterns-example_check_pedestrian_flow
911914

915+
.rules:build:example_display_lcd_hdmi_video_renderer:
916+
rules:
917+
- <<: *if-protected
918+
- <<: *if-label-build
919+
- <<: *if-trigger-job
920+
912921
.rules:build:example_display_lcd_lcd_layer_blending:
913922
rules:
914923
- <<: *if-protected

examples/.build-rules.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ examples/check_pedestrian_flow:
167167
enable:
168168
- if: IDF_TARGET in ["esp32","esp32s2","esp32s3","esp32c3"]
169169

170+
examples/display/lcd/hdmi_video_renderer:
171+
enable:
172+
- if: IDF_TARGET in ["esp32p4"]
173+
170174
examples/display/lcd/lcd_layer_blending:
171175
enable:
172176
- if: IDF_TARGET in ["esp32p4"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# For more information about build system see
2+
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
3+
# The following five lines of boilerplate have to be in your project's
4+
# CMakeLists in this exact order for cmake to work correctly
5+
cmake_minimum_required(VERSION 3.5)
6+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
7+
add_compile_options("-Wno-attributes")
8+
project(mipi_dsi_avoid_tearing)
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
| Supported Targets | ESP32-P4 |
2+
| ----------------- | -------- |
3+
4+
# HDMI Video Renderer
5+
6+
This example demonstrates how to display a video in MP4/AVI format on an HDMI monitor.
7+
8+
## How to use the example
9+
10+
## ESP-IDF Required
11+
12+
### Hardware Required
13+
14+
* An ESP32-P4-Function-EV-Board.
15+
* An [ESP-HDMI-Bridge](https://oshwhub.com/esp-college/esp-hdmi-bridge).
16+
* An SD card that stores MP4 videos.
17+
* A USB-C cable for power supply and programming.
18+
* Please refer to the following steps for the connection:
19+
* **Step 1**. According to the table below, connect the pins on the back of the screen adapter board to the corresponding pins on the development board.
20+
21+
| ESP-HDMI-Bridge | ESP32-P4-Function-EV-Board |
22+
| -------------------- | -------------------------- |
23+
| 5V (any one) | 5V (any one) |
24+
| GND (any one) | GND (any one) |
25+
26+
* **Step 2**. Connect the FPC of LCD through the `MIPI_DSI` interface.
27+
* **Step 3**. Use a USB-C cable to connect the `USB-UART` port to a PC (Used for power supply and viewing serial output).
28+
* **Step 4**. Turn on the power switch of the board.
29+
30+
### Configure the Project
31+
32+
Run `idf.py menuconfig` and navigate to `HDMI MP4 Player Configuration` menu.
33+
34+
- Navigate to `Video File Configuration` submenu
35+
- Set the `Video File Name` to match your video file name stored in the SD card
36+
- Default value is `test_video.mp4`
37+
- Make sure the file name matches exactly, including the `.mp4` or `.avi` extension
38+
39+
### Test Video Downloads
40+
41+
This repository provides a test MP4 file encoded with MJPEG video and AAC audio for testing and compatibility purposes.
42+
43+
- **Video Codec**: MJPEG
44+
- **Audio Codec**: AAC
45+
- **Frame Rate**: 20fps(RGB888)
46+
- **File Format**: `.mp4`
47+
- **Download Link**: [test_video.mp4](https://dl.espressif.com/AE/esp-dev-kits/test_video.mp4)
48+
49+
This test file is useful for validating MJPEG decoding, AAC audio support, and embedded system playback compatibility.
50+
51+
### Build and Flash
52+
53+
Run `idf.py set-target esp32p4` to select the target chip.
54+
55+
Run `idf.py -p PORT build flash monitor` to build, flash and monitor the project. A fancy animation will show up on the LCD as expected.
56+
57+
The first time you run `idf.py` for the example will cost extra time as the build system needs to address the component dependencies and downloads the missing components from registry into `managed_components` folder.
58+
59+
(To exit the serial monitor, type ``Ctrl-]``.)
60+
61+
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
62+
63+
## Troubleshooting
64+
65+
For any technical queries, please open an [issue](https://github.com/espressif/esp-iot-solution/issues) on GitHub. We will get back to you soon.
66+
67+
## Important Notes
68+
69+
### Video Format Requirements
70+
71+
1. **MP4 Container Format**
72+
- Currently only supports MP4 files with MJPEG video encoding
73+
- Other video codecs (H.264, H.265, etc.) are not supported at this time
74+
- Audio tracks in MP4 files are supported
75+
76+
2. **Video Resolution and Format**
77+
- For YUV420 format videos:
78+
* Width must be divisible by 16
79+
* Height must be divisible by 16
80+
* This alignment requirement ensures optimal performance and compatibility
81+
- For YUV422 format videos:
82+
* Width must be divisible by 16
83+
* Height must be divisible by 8
84+
* Provides better color quality than YUV420 but requires more bandwidth
85+
- For YUV444 format videos:
86+
* Width must be divisible by 8
87+
* Height must be divisible by 8
88+
* Offers the highest color quality but requires the most bandwidth
89+
90+
3. **Display Buffer Configuration**
91+
- When using LCD internal buffer mode:
92+
* Video resolution must exactly match the HDMI output resolution
93+
* This ensures optimal performance and prevents display artifacts
94+
* Example: If HDMI is set to 1280x720, the MP4 must also be 1280x720
95+
- When using external buffer mode:
96+
* More flexible resolution support
97+
* Automatic scaling is available
98+
* May have slightly lower performance compared to internal buffer mode
99+
100+
### FAQ
101+
102+
#### Blue Screen Flickering Issues
103+
104+
If you encounter blue screen flickering during video playback, this is typically caused by **insufficient PSRAM bandwidth**. Here are the recommended solutions:
105+
106+
1. **Use RGB565 Format**
107+
- If your display supports RGB565, consider switching from RGB888 to RGB565 format
108+
109+
2. **Optimize Video Parameters**
110+
- **Lower Resolution**: Reduce video resolution (e.g., from 1280x720 to 1024x768)
111+
- **Reduce Frame Rate**: Lower the video frame rate (e.g., from 30fps to 20fps or 15fps)
112+
- **Increase Compression**: Use higher JPEG compression quality to reduce frame sizes
113+
114+
3. **AVI Format Audio Limitations**
115+
- **AVI videos with audio are not recommended** due to higher bandwidth requirements
116+
- If playing AVI files causes blue screen flickering, **disable audio playback**
117+
- For audio playback, use MP4 format with AAC encoding instead
118+
119+
These optimizations help balance video quality with available system bandwidth to ensure stable playback.
120+
121+
## Video Conversion with FFmpeg
122+
123+
### Installation
124+
```bash
125+
# Windows: Download from https://ffmpeg.org/download.html
126+
# macOS: brew install ffmpeg
127+
# Linux: sudo apt install ffmpeg
128+
```
129+
130+
### Basic MJPEG Conversion
131+
```bash
132+
# Convert any video to MJPEG MP4
133+
ffmpeg -i input.mp4 -c:v mjpeg -c:a aac output.mp4
134+
```
135+
136+
### Recommended Settings
137+
138+
**High Quality (1280x720, RGB888 displays):**
139+
```bash
140+
ffmpeg -i input.mp4 -c:v mjpeg -q:v 3 -vf scale=1280:720 -r 20 -c:a aac output.mp4
141+
```
142+
143+
**Balanced (1024x768, recommended):**
144+
```bash
145+
ffmpeg -i input.mp4 -c:v mjpeg -q:v 5 -vf scale=1024:768 -r 20 -c:a aac output.mp4
146+
```
147+
148+
**Low Bandwidth (800x600, RGB565 or troubleshooting):**
149+
```bash
150+
ffmpeg -i input.mp4 -c:v mjpeg -q:v 8 -vf scale=800:600 -r 15 -c:a aac output.mp4
151+
```
152+
153+
### Key Parameters
154+
- `-q:v`: Quality (1-31, lower = better quality, larger file)
155+
- `-vf scale=W:H`: Resolution adjustment
156+
- `-r`: Frame rate (15-25 fps recommended)
157+
- `-an`: Remove audio if causing issues
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
idf_component_register(
2+
SRCS "esp_extractor_reg.c"
3+
INCLUDE_DIRS "include"
4+
#PRIV_REQUIRES esp_es_parse
5+
)
6+
7+
add_prebuilt_library(extractor "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CONFIG_IDF_TARGET}/libesp_extractor.a")
8+
target_link_libraries(${COMPONENT_LIB} PRIVATE extractor)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
menu "Extractor Configuration"
2+
3+
config WAV_EXTRACTOR_SUPPORT
4+
bool "Support WAV Extractor"
5+
default y
6+
help
7+
Enable this option to register WAV Extractor
8+
9+
config MP4_EXTRACTOR_SUPPORT
10+
bool "Support MP4 Extractor"
11+
default y
12+
help
13+
Enable this option to register MP4 Extractor
14+
15+
config TS_EXTRACTOR_SUPPORT
16+
bool "Support TS Extractor"
17+
default y
18+
help
19+
Enable this option to register TS Extractor
20+
21+
config HLS_EXTRACTOR_SUPPORT
22+
bool "Support HLS (m3u8) Extractor"
23+
default y
24+
help
25+
Enable this option to register HLS Extractor
26+
27+
config OGG_EXTRACTOR_SUPPORT
28+
bool "Support OGG Extractor"
29+
default y
30+
help
31+
Enable this option to register OGG extractor
32+
33+
config AVI_EXTRACTOR_SUPPORT
34+
bool "Support AVI Extractor"
35+
default y
36+
help
37+
Enable this option to register AVI Extractor
38+
39+
config AUDIO_ES_EXTRACTOR_SUPPORT
40+
bool "Support Audio ES Extractor"
41+
default y
42+
help
43+
Enable this option to register (aac, mp3, flac, amr etc) Extractor
44+
45+
config CAF_EXTRACTOR_SUPPORT
46+
bool "Support CALF Extractor"
47+
default y
48+
help
49+
Enable this option to register CALF Extractor
50+
51+
config FLV_EXTRACTOR_SUPPORT
52+
bool "Support FLV Extractor"
53+
default y
54+
help
55+
Enable this option to register FLV Extractor
56+
endmenu

0 commit comments

Comments
 (0)