Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P PyAV
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 37
    • Issues 37
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyAV
  • PyAV
  • Merge requests
  • !1035

Clarify "rate" properties by deprecating aliases

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Jeremy Lainé requested to merge github/fork/jlaine/deprecate-rate-aliases into main 2 years ago
  • Overview 3
  • Commits 1
  • Pipelines 0
  • Changes 6

We have multiple properties referring to "rates", some of which go by a generic "rate" name without specifying whether it is a frame rate or a sample rate.

This change deprecates:

  • AudioCodecContext.rate (use AudioCodecContext.sample_rate)
  • AudioFrame.rate (use AudioFrame.sample_rate)
  • VideoCodecContext.rate (use VideoCodecContext.framerate)
Compare
  • main (base)

and
  • latest version
    4041ea8a
    1 commit, 2 years ago

6 files
+ 9
- 24

    Preferences

    File browser
    Compare changes
a‎v‎
au‎dio‎
codeccon‎text.pyx‎ +2 -7
fram‎e.pyx‎ +2 -7
resamp‎ler.pyx‎ +1 -1
strea‎m.pyx‎ +1 -1
vi‎deo‎
codeccon‎text.pyx‎ +2 -7
strea‎m.pyx‎ +1 -1
av/audio/codeccontext.pyx
+ 2
- 7
  • View file @ 4041ea8a


cimport libav as lib
from av import deprecation
from av.audio.format cimport AudioFormat, get_audio_format
from av.audio.frame cimport AudioFrame, alloc_audio_frame
from av.audio.layout cimport AudioLayout, get_audio_layout
@@ -75,13 +76,7 @@ cdef class AudioCodecContext(CodecContext):
def __set__(self, int value):
self.ptr.sample_rate = value
property rate:
"""Another name for :attr:`sample_rate`."""
def __get__(self):
return self.sample_rate
def __set__(self, value):
self.sample_rate = value
rate = deprecation.renamed_attr("sample_rate")
# TODO: Integrate into AudioLayout.
property channels:
av/audio/frame.pyx
+ 2
- 7
  • View file @ 4041ea8a


from av import deprecation
from av.audio.format cimport get_audio_format
from av.audio.layout cimport get_audio_layout
from av.audio.plane cimport AudioPlane
@@ -165,13 +166,7 @@ cdef class AudioFrame(Frame):
def __set__(self, value):
self.ptr.sample_rate = value
property rate:
"""Another name for :attr:`sample_rate`."""
def __get__(self):
return self.ptr.sample_rate
def __set__(self, value):
self.ptr.sample_rate = value
rate = deprecation.renamed_attr("sample_rate")
def to_ndarray(self, **kwargs):
"""Get a numpy array of this frame.
av/audio/resampler.pyx
+ 1
- 1
  • View file @ 4041ea8a


@@ -94,7 +94,7 @@ cdef class AudioResampler(object):
if (
frame.format.sample_fmt != self.template.format.sample_fmt or
frame.layout.layout != self.template.layout.layout or
frame.sample_rate != self.template.rate
frame.sample_rate != self.template.sample_rate
):
raise ValueError('Frame does not match AudioResampler setup.')
av/audio/stream.pyx
+ 1
- 1
  • View file @ 4041ea8a


@@ -5,7 +5,7 @@ cdef class AudioStream(Stream):
self.__class__.__name__,
self.index,
self.name,
self.rate,
self.sample_rate,
self.layout.name,
self.format.name if self.format else None,
id(self),
av/video/codeccontext.pyx
+ 2
- 7
  • View file @ 4041ea8a


from libc.stdint cimport int64_t
cimport libav as lib
from av import deprecation
from av.codec.context cimport CodecContext
from av.error cimport err_check
from av.frame cimport Frame
@@ -118,13 +119,7 @@ cdef class VideoCodecContext(CodecContext):
def __set__(self, value):
to_avrational(value, &self.ptr.framerate)
property rate:
"""Another name for :attr:`framerate`."""
def __get__(self):
return self.framerate
def __set__(self, value):
self.framerate = value
rate = deprecation.renamed_attr("framerate")
property gop_size:
def __get__(self):
av/stream.pyx
+ 1
- 1
  • View file @ 4041ea8a


@@ -219,7 +219,7 @@ cdef class Stream(object):
The average frame rate of this video stream.
This is calculated when the file is opened by looking at the first
few frames and averaging their rate.
few frames and averaging their rate. See :ffmpeg:`AVStream.avg_frame_rate`
:type: :class:`~fractions.Fraction` or ``None``
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
2
2 participants
Jeremy Lainé
Administrator
Reference: PyAV-Org/PyAV!1035
Source branch: github/fork/jlaine/deprecate-rate-aliases

Menu

Explore Projects Groups Snippets