Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions av/video/codeccontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,22 @@ def pix_fmt(self):
def pix_fmt(self, value):
self.ptr.pix_fmt = get_pix_fmt(value)

@property
def sw_format(self):
"""
For a hardware context (e.g. ``format.name == "cuda"``), the underlying
software pixel format (``nv12``, ``p010le``, ...). ``None`` for a regular
software context.

:type: VideoFormat | None
"""
if not self.ptr.hw_frames_ctx:
return None
frames_ctx: cython.pointer[lib.AVHWFramesContext] = cython.cast(
cython.pointer[lib.AVHWFramesContext], self.ptr.hw_frames_ctx.data
)
return get_video_format(frames_ctx.sw_format, self.ptr.width, self.ptr.height)

@property
def framerate(self):
"""
Expand Down
1 change: 1 addition & 0 deletions av/video/codeccontext.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class VideoCodecContext(CodecContext):
height: int
bits_per_coded_sample: int
pix_fmt: str | None
sw_format: VideoFormat | None
framerate: Fraction
rate: Fraction
gop_size: int
Expand Down
Loading