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
13 changes: 13 additions & 0 deletions av/codec/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,19 @@ def profile(self, value):
return
i += 1

@property
def level(self):
"""Codec level.

Wraps :ffmpeg:`AVCodecContext.level`.

"""
return self.ptr.level

@level.setter
def level(self, value: cython.int):
self.ptr.level = value

@property
def time_base(self):
if self.is_decoder:
Expand Down
1 change: 1 addition & 0 deletions av/codec/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class CodecContext:
type: Literal["video", "audio", "data", "subtitle", "attachment"]
options: dict[str, str]
profile: str | None
level: int
@property
def profiles(self) -> list[str]: ...
extradata: bytes | None
Expand Down
1 change: 1 addition & 0 deletions include/avcodec.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ cdef extern from "libavcodec/avcodec.h" nogil:
int thread_type
int bits_per_coded_sample
int profile
int level
AVDiscard skip_frame

int subtitle_header_size
Expand Down
8 changes: 8 additions & 0 deletions tests/test_codec_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def test_global_quality(self):
ctx.global_quality = 5
assert ctx.global_quality == 5

def test_level(self):
with av.open(fate_suite("h264/interlaced_crop.mp4")) as container:
assert container.streams.video[0].codec_context.level == 41

ctx = Codec("mpeg4", "w").create()
ctx.level = 5
assert ctx.level == 5

def test_skip_frame_default(self):
ctx = Codec("png", "w").create()
assert ctx.skip_frame == "DEFAULT"
Expand Down
Loading