Skip to content

Encode GPU frames with pix_fmt=cuda, expose#2328

Merged
WyattBlue merged 2 commits into
mainfrom
patch
Jun 24, 2026
Merged

Encode GPU frames with pix_fmt=cuda, expose#2328
WyattBlue merged 2 commits into
mainfrom
patch

Conversation

@WyattBlue

Copy link
Copy Markdown
Member

Encode GPU frames with pix_fmt=cuda, expose VideoFrame.sw_format

A hardware frame (e.g. a CUDA frame from DLPack) carries its own frames context. nvenc and friends require hw_frames_ctx to be set before avcodec_open2, so adopt the frame's before opening the encoder. This lets GPU frames encode on-device with no download/upload round-trip.

Also expose VideoFrame.sw_format, which returns the underlying software pixel format (nv12, yuv444p, p010le, ...) for a hardware frame and None otherwise.

closes #2199

Encode GPU frames with pix_fmt=cuda, expose VideoFrame.sw_format

A hardware frame (e.g. a CUDA frame from DLPack) carries its own frames
context. nvenc and friends require hw_frames_ctx to be set before
avcodec_open2, so adopt the frame's before opening the encoder. This lets
GPU frames encode on-device with no download/upload round-trip.

Also expose VideoFrame.sw_format, which returns the underlying software
pixel format (nv12, yuv444p, p010le, ...) for a hardware frame and None
otherwise.

closes #2199
@WyattBlue WyattBlue merged commit a4167d5 into main Jun 24, 2026
8 checks passed
@WyattBlue WyattBlue deleted the patch branch June 24, 2026 21:02
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.

Support pix_fmt="cuda" in video codec context.

1 participant