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/video/codeccontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,19 @@ def colorspace(self):
def colorspace(self, value):
self.ptr.colorspace = value

@property
def field_order(self):
"""The video field order as FFmpeg's raw integer value.

Wraps :ffmpeg:`AVCodecContext.field_order`.

"""
return self.ptr.field_order

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

@property
def max_b_frames(self):
"""
Expand Down
1 change: 1 addition & 0 deletions av/video/codeccontext.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class VideoCodecContext(CodecContext):
color_primaries: int
color_trc: int
colorspace: int
field_order: int
qmin: int
qmax: int
type: Literal["video"]
Expand Down
1 change: 1 addition & 0 deletions include/avcodec.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ cdef extern from "libavcodec/avcodec.h" nogil:
AVColorTransferCharacteristic color_trc
AVColorSpace colorspace
AVColorRange color_range
int field_order

int has_b_frames
AVPixelFormat (*get_format)(AVCodecContext *s, const AVPixelFormat *fmt)
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 @@ -83,6 +83,14 @@ def test_level(self):
ctx.level = 5
assert ctx.level == 5

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

ctx = Codec("mpeg4", "w").create()
ctx.field_order = 1
assert ctx.field_order == 1

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