Skip to content

Commit 1705772

Browse files
committed
Test opaque
1 parent b824d26 commit 1705772

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

av/codec/context.pyi

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,29 @@ class CodecContext:
7373
thread_type: Any
7474
skip_frame: Any
7575

76+
# flgas
77+
unaligned: bool
78+
qscale: bool
79+
four_mv: bool
80+
output_corrupt: bool
81+
qpel: bool
82+
drop_changed: bool
83+
recon_frame: bool
84+
copy_opaque: bool
85+
frame_duration: bool
86+
pass1: bool
87+
pass2: bool
88+
loop_filter: bool
89+
gray: bool
90+
psnr: bool
91+
interlaced_dct: bool
92+
low_delay: bool
93+
global_header: bool
94+
bitexact: bool
95+
ac_pred: bool
96+
interlaced_me: bool
97+
closed_gop: bool
98+
7699
def open(self, strict: bool = True) -> None: ...
77100
def close(self, strict: bool = True) -> None: ...
78101
@staticmethod

av/frame.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ class Frame:
77
time_base: Fraction
88
is_corrupt: bool
99
side_data: dict[str, str]
10+
opaque: object
1011

1112
def make_writable(self) -> None: ...

av/packet.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Packet(Buffer):
1414
pos: int | None
1515
size: int
1616
duration: int | None
17+
opaque: object
1718
is_keyframe: bool
1819
is_corrupt: bool
1920
is_discard: bool

tests/test_videoframe.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
import time
12
from fractions import Fraction
23
from unittest import SkipTest
34

45
import numpy
56

7+
import av
68
from av import VideoFrame
79

8-
from .common import TestCase, fate_png, has_pillow
10+
from .common import TestCase, fate_png, fate_suite, has_pillow
11+
12+
13+
class TestOpaque:
14+
def test_opaque(self) -> None:
15+
with av.open(fate_suite("h264/interlaced_crop.mp4")) as container:
16+
video_stream = container.streams.video[0]
17+
video_stream.codec_context.copy_opaque = True
18+
for packet_idx, packet in enumerate(container.demux()):
19+
packet.opaque = (time.time(), packet_idx)
20+
for frame in packet.decode():
21+
assert isinstance(frame, av.frame.Frame)
22+
assert type(frame.opaque) is tuple and len(frame.opaque) == 2
923

1024

1125
class TestVideoFrameConstructors(TestCase):
@@ -33,7 +47,7 @@ def test_manual_rgb_constructor(self):
3347
assert frame.format.name == "rgb24"
3448

3549

36-
class TestVideoFramePlanes(TestCase):
50+
class TestVideoFramePlanes:
3751
def test_null_planes(self):
3852
frame = VideoFrame() # yuv420p
3953
assert len(frame.planes) == 0

0 commit comments

Comments
 (0)