obsproject / obsproject/obs-studio

NV12 video capture preview shows garbled image for resolutions 800x480,800x800 due to unhandled pitch/stride

Open
#13,189 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

32.0.4

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/5HpEIP3NbUVXYcU0

OBS Studio Crash Log URL

No response

Expected Behavior

OBS should correctly display NV12 video frames from DirectShow capture devices even when the frame lines have padding (pitch/stride) that differs from the image width.

Current Behavior

When capturing from a camera that provides NV12 frames with a pitch larger than the image width (e.g., 800×480, 800×800, pitch = 832 bytes), the preview in OBS appears garbled (image lines are misaligned, causing a “broken” picture). This affects resolutions whose width is not a multiple of 64. Other applications such as the Windows Camera App display the same resolution correctly, indicating they handle pitch properly.
OBS:
Image
Windows Camera App:
Image

Steps to Reproduce

1.Connect a camera that outputs NV12 format and supports a resolution with width not a multiple of 64 (e.g., 800×800, 800×480, 480×480, etc.).
2.In OBS, add a “Video Capture Device” source.
3.Select the camera and set the resolution to one of the affected ones (for example, 800×480).
4.Observe the preview – the image is distorted (garbled lines).

Anything else we should know?

Affected resolutions (tested):
800×800
800×480
160×160
480×480
816×816
1120×1120
672×672
Resolutions with width that is a multiple of 64 (e.g., 640×640, 960×960, 1600×900) work correctly.
Root cause analysis:
NV12 frames may have a line pitch (stride) that is larger than the image width due to memory alignment requirements. When OBS reads the frame, it currently assumes the data is tightly packed (width × height × 1.5 bytes). It does not take the actual pitch into account, leading to line misalignment when copying.

The Windows Camera app can display these resolutions normally, and we believe OBS should be able to do the same. Please help fix this issue. Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in OBS Studio’s DirectShow video capture handling and trace how NV12 frames are copied into the preview. Reproduce with the listed non-multiple-of-64 resolutions, then verify that the actual pitch is respected and that 800×480, 800×800, and the other affected sizes display correctly without regressing working widths.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
audio-video-rtc, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.