Skip to content

Commit

Permalink
Move key_frame attribute to Frame class
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Nov 10, 2024
1 parent 2341842 commit 05dfa60
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
9 changes: 6 additions & 3 deletions av/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ class SideData(TypedDict, total=False):
class Frame:
dts: int | None
pts: int | None
time: float | None
time_base: Fraction
is_corrupt: bool
side_data: SideData
opaque: object

@property
def time(self) -> float | None: ...
@property
def is_corrupt(self) -> bool: ...
@property
def key_frame(self) -> bool: ...
def make_writable(self) -> None: ...
10 changes: 10 additions & 0 deletions av/frame.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ cdef class Frame:
"""
return self.ptr.decode_error_flags != 0 or bool(self.ptr.flags & lib.AV_FRAME_FLAG_CORRUPT)

@property
def key_frame(self):
"""Is this frame a key frame?
Wraps :ffmpeg:`AVFrame.key_frame`.
"""
return bool(self.ptr.key_frame)


@property
def side_data(self):
if self._side_data is None:
Expand Down
1 change: 0 additions & 1 deletion av/video/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class VideoFrame(Frame):
planes: tuple[VideoPlane, ...]
width: int
height: int
key_frame: bool
interlaced_frame: bool
pict_type: int
colorspace: int
Expand Down
13 changes: 0 additions & 13 deletions av/video/frame.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,11 @@ cdef class VideoFrame(Frame):
"""Width of the image, in pixels."""
return self.ptr.width


@property
def height(self):
"""Height of the image, in pixels."""
return self.ptr.height


@property
def key_frame(self):
"""Is this frame a key frame?
Wraps :ffmpeg:`AVFrame.key_frame`.
"""
return self.ptr.key_frame


@property
def interlaced_frame(self):
"""Is this frame an interlaced or progressive?
Expand All @@ -196,7 +184,6 @@ cdef class VideoFrame(Frame):
"""
return self.ptr.interlaced_frame


@property
def pict_type(self):
"""One of :class:`.PictureType`.
Expand Down

0 comments on commit 05dfa60

Please sign in to comment.