Skip to content

Add color correction and dvr-reencode#115

Merged
henkwiedig merged 26 commits into
OpenIPC:masterfrom
henkwiedig:colortans2
Mar 16, 2026
Merged

Add color correction and dvr-reencode#115
henkwiedig merged 26 commits into
OpenIPC:masterfrom
henkwiedig:colortans2

Conversation

@henkwiedig
Copy link
Copy Markdown
Collaborator

This PR introduces DRM and GPU-accelerated color correction, a hardware re-encoder for DVR recording, OSD-recording.

Key Features

  • Applies a linear, cpu free color transform useing a drm LUT on the display path
  • Applies the inverse color transform to the OSD/overlay buffer via GPU so OSD stays visually orrect when the video color transform is active
  • Applies a linear color transform to video frames using EGL/GLES2 shaders on the GPU
  • New Rockchip MPP-based H.264/H.265 re-encoder for DVR recording
  • Blends the OSD onto recorded video frames so recordings include the on-screen display
image

This was heavily inspired by @sickgreg's patch.
AI assisted code.

@DmtryJS
Copy link
Copy Markdown
Contributor

DmtryJS commented Mar 6, 2026

Hi! Thanks for nice feature!
I conducted several tests and it is works good.

  1. default mode record disabled and live colortrans = off measurement of utilization using htop
  2. utilization measurement with live colortrans = on enabled
  3. utilization measurement with record without Re-encode
  4. utilization measurement with record with Re-encode h264 codec 30fps 8000 record osd option enabled
  5. utilization measurement with record with Re-encode h264 codec 30fps 8000 record osd option disabled
  6. utilization measurement with record with Re-encode h265 codec 60fps 8000 record osd option disabled

Regarding CPU utilization, I didn't notice any problems at all - the load seemingly doesn't change whether reencode is enabled or disabled. about 25-28 % utilization

Unfortunately, I don't have the ability to measure latency.

I noticed one issue with DVR recording: if you select h264 codec and enable reencode, the recording won't play in the built-in DVR player (if you download the video to the main computer, it opens correctly). With h265 codec everything is fine. My system settings have h265 codec enabled as well, if that's important. Could you recheck this on your setup ?

I'm also attaching videos - DVR with "record OSD in DVR" option enabled and disabled.
With the option enabled, a widget showing video link quality appears in the top right corner. My video is somewhat distorted but this is due to the non-standard screen size 1440x1440. I think this wouldn't happen on standard screens.
When disabling "record OSD in DVR" and then restarting pixelpilot, all telemetry from the flight controller and what adaptive link transmits gets recorded to video.

Is this expected behavior? "record OSD in DVR" switch adds/removes link quality widget in the top right corner of DVR and possibly other such widgets like IN216.

265codec_60fps_on_osd_recording
https://youtu.be/NXWfCOaSq8A

265codec_60fps_off_osd_recording
https://youtu.be/BBWXB0gcjiw

dvr with color enchancment
https://youtu.be/rgqUnN3oMUE

system utilization while recording dvr with reencode to 265 codec 60fps osd disabled
https://youtu.be/4wspVkEswwM

system utilization withour reencode and color enchancment (stock default case)
https://youtu.be/DIyoovEblao

@henkwiedig
Copy link
Copy Markdown
Collaborator Author

@DmtryJS You are correct, the "record OSD in DVR" only records the osd generated from the VRX, not the one which alreaday was in the video.
You can use GS Rendering in which case the video will be clean of osd elements and osd will be entirely generated by the vrx, in that case the "record OSD in DVR" includes the "flightcontroller" osd a.k.a. MSP Disaplyport.

DVR in mixed h264/h265 modes. This is actually a bug in the DVR player. Currently DVR assumes the recorded video to be in the formart your are currently receiving live video. It does not auto detect the format. I would like to fix this outside this PR in order to not make it too large. Feel free to create an issue for this.

There is another issue with the DVR.
When dvr has applied the colortrans the recorded video is "real color" but when dvr plays while "live colortrans" is enabled the colortrans get's applied twice. don't know if this is large issue.

@DmtryJS
Copy link
Copy Markdown
Contributor

DmtryJS commented Mar 15, 2026

Hi! I tried the latest build, color correction and re-encoding work great, and playback of DVR recorded with the H.265 codec now works. Interesting feature of recording two streams simultaneously: if you select GS rendering set to VTX and VRX, you get two streams — one completely clean without any OSD, and the second with OSD (there is an issue with OSD rendering if the resolution in Pixelpilot differs from the actual display resolution, for example, my display only supports 1440x1440 and there's no way to change that, but that's a separate problem, not part of this request).

@henkwiedig henkwiedig marked this pull request as ready for review March 15, 2026 21:11
@henkwiedig henkwiedig merged commit 21872fd into OpenIPC:master Mar 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants