Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some docstrings for Frame base class #372

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
35 changes: 33 additions & 2 deletions av/frame.pyx
Expand Up @@ -9,8 +9,11 @@ from fractions import Fraction


cdef class Frame(object):
"""
Base class for audio and video frames.

"""Frame Base Class"""
See also :class:`~av.audio.frame.AudioFrame` and :class:`~av.video.frame.VideoFrame`.
"""

def __cinit__(self, *args, **kwargs):
with nogil:
Expand Down Expand Up @@ -89,14 +92,25 @@ cdef class Frame(object):

self._time_base = dst


property dts:
"""
The decoding timestamp in :attr:`time_base` units for this frame.

:type: int
"""
def __get__(self):
if self.ptr.pkt_dts == lib.AV_NOPTS_VALUE:
return None
return self.ptr.pkt_dts

property pts:
"""
The presentation timestamp in :attr:`time_base` units for this frame.

This is the time at which the frame should be shown to the user.

:type: int
"""
def __get__(self):
if self.ptr.pts == lib.AV_NOPTS_VALUE:
return None
Expand All @@ -108,18 +122,35 @@ cdef class Frame(object):
self.ptr.pts = value

property time:
"""
The presentation time in seconds for this frame.

This is the time at which the frame should be shown to the user.

:type: float
"""
def __get__(self):
if self.ptr.pts == lib.AV_NOPTS_VALUE:
return None
else:
return float(self.ptr.pts) * self._time_base.num / self._time_base.den

property time_base:
"""
The unit of time (in fractional seconds) in which timestamps are expressed.

:type: fractions.Fraction
"""
def __get__(self):
if self._time_base.num:
return avrational_to_faction(&self._time_base)
def __set__(self, value):
to_avrational(value, &self._time_base)

property is_corrupt:
"""
Is this frame corrupt?

:type: bool
"""
def __get__(self): return self.ptr.decode_error_flags != 0 or bool(self.ptr.flags & lib.AV_FRAME_FLAG_CORRUPT)