I’m working with ESP-P4 using the `esp_video` driver and an OV5647 camera over MIPI-CSI. I’m trying to configure the camera for **exact 640×480 output in RGB565**, but I’m facing issues with resolution and frame layout.
### What I’m doing
I set the format using V4L2:
Code: Select all
fmt.fmt.pix.width = 640;
fmt.fmt.pix.height = 480;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB565;
ioctl(fd, VIDIOC_S_FMT, &fmt);
ioctl(fd, VIDIOC_G_FMT, &fmt);
* `VIDIOC_S_FMT` returns failure (`Failed to set format`)
* `VIDIOC_G_FMT` still reports:
* Resolution: **640×480**
* Format: **RGBP (RGB565)**
* However, `bytesperline` is larger than expected:
* Expected: `640 * 2 = 1280`
* Actual: e.g. `1600`
This causes:
* Frame stride mismatch
* Corrupted / shifted image when encoding directly
### What I tried
* Using `bytesperline` instead of width → fixes corruption but not true 640 width
* Cropping buffer manually → works but adds overhead
* Attempted to use `VIDIOC_S_SENSOR_FMT` (from examples), but:
* `v4l2_sensor_format` is not available in public headers
### My questions
1. Is it possible to **force true sensor-level 640×480 (no padding / no scaling)** using `esp_video`?
2. Is `VIDIOC_S_SENSOR_FMT` supported for OV5647 in ESP-IDF v5.5.3?
3. Is there a recommended way to:
* Disable stride padding?
* Or get exact frame width without cropping?
4. Is the driver internally fixing alignment (e.g. 800 width), and if so, can this be configured?
### Goal
I want a **clean 640×480 RGB565 frame (bytesperline = 1280)** directly from the driver, without needing software cropping.
Any guidance would be really helpful. Thanks!
---
**Platform details:**
* ESP-IDF: v5.5.3
* Target: ESP-P4
* Camera: OV5647 (MIPI CSI)
* Driver: esp_video