Skip to content

Fix occasional green artifact when using NVENC and uvc camera#1135

Merged
chenosaurus merged 3 commits into
mainfrom
dc/exp/nvenc_corrupt_frame
Jun 4, 2026
Merged

Fix occasional green artifact when using NVENC and uvc camera#1135
chenosaurus merged 3 commits into
mainfrom
dc/exp/nvenc_corrupt_frame

Conversation

@chenosaurus
Copy link
Copy Markdown
Contributor

Summary

Fixes NVIDIA hardware-encoded local_video publisher corruption that showed up as green stripes or intermittent green artifacts on subscribers.

What changed

  • Stop reusing the same mutable I420 frame buffer after handing frames to WebRTC.
  • Copy NVENC I420 input planes independently using each plane’s actual stride instead of assuming Y/U/V are tightly packed from DataY() and StrideY().
  • Applies the NVENC plane-copy fix to both H.264 and H.265 encoders.

Why

WebRTC/NVENC can consume captured frames asynchronously, so reusing the same backing buffer could overwrite frames still in flight. Separately, padded I420 buffers, such as frames prepared for local preview/display, can have UV strides that do not derive from the Y stride. The old NVENC upload path could therefore read the wrong chroma data.

@chenosaurus chenosaurus marked this pull request as ready for review June 4, 2026 06:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

Changeset

The following package versions will be affected by this PR:

Package Bump
libwebrtc patch
livekit patch
webrtc-sys patch

@chenosaurus chenosaurus merged commit 8d8028b into main Jun 4, 2026
26 of 27 checks passed
@chenosaurus chenosaurus deleted the dc/exp/nvenc_corrupt_frame branch June 4, 2026 16:08
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