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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Features:
- Add Bayer pixel formats by :gh-user:`z-khan` in (:pr:`1755`).
- Add support for yuv422p10le pix_fmt by :gh-user:`WyattBlue` in (:pr:`1767`).
- Add ``supported_np_pix_fmts`` by :gh-user:`WyattBlue` in (:pr:`1766`).
- Add ``Codec.canonical_name`` by :gh-user:`WyattBlue`.

Misc.
- Drop support for MacOS 11 by :gh-user:`WyattBlue` in (:pr:`1764`).
Expand Down
2 changes: 2 additions & 0 deletions av/codec/codec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Codec:
@property
def name(self) -> str: ...
@property
def canonical_name(self) -> str: ...
@property
def long_name(self) -> str: ...
@property
def type(self) -> Literal["video", "audio", "data", "subtitle", "attachment"]: ...
Expand Down
9 changes: 9 additions & 0 deletions av/codec/codec.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cimport libav as lib

from av.audio.format cimport get_audio_format
from av.codec.hwaccel cimport wrap_hwconfig
from av.descriptor cimport wrap_avclass
Expand Down Expand Up @@ -144,6 +146,13 @@ cdef class Codec:
@property
def name(self): return self.ptr.name or ""

@property
def canonical_name(self):
"""
Returns the name of the codec, not a specific encoder.
"""
return lib.avcodec_get_name(self.ptr.id)

@property
def long_name(self): return self.ptr.long_name or ""

Expand Down
1 change: 1 addition & 0 deletions tests/test_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_codec_opus_decoder() -> None:
def test_codec_opus_encoder() -> None:
c = Codec("opus", "w")
assert c.name in ("opus", "libopus")
assert c.canonical_name == "opus"
assert c.long_name in ("Opus", "libopus Opus")
assert c.type == "audio"
assert c.is_encoder
Expand Down
Loading