Skip to content

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

@lovezhangtao

Description

@lovezhangtao

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions