Skip to content

Commit

Permalink
Improve type stub
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Dec 9, 2023
1 parent 7abe91b commit da08233
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
4 changes: 1 addition & 3 deletions av/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ def main():
parser.add_argument("--version", action="store_true")
args = parser.parse_args()

# ---

if args.version:
import av
import av._core

print("PyAV v" + av.__version__)
print(f"PyAV v{av.__version__}")

by_config = {}
for libname, config in sorted(av._core.library_meta.items()):
Expand Down
3 changes: 0 additions & 3 deletions av/codec/context.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,3 @@ class CodecContext:
@staticmethod
def create(codec, mode=None) -> CodecContext: ...
def parse(self, raw_input=None) -> list: ...
def encode(self, frame: Frame | None = None) -> list[Packet]: ...
def encode_lazy(self, frame: Frame | None = None) -> Iterator[Packet]: ...
def decode(self, packet: Packet | None = None) -> list[Frame]: ...
4 changes: 2 additions & 2 deletions av/filter/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .filter import Filter, filters_available
from .graph import Graph
from .filter import *
from .graph import *
3 changes: 1 addition & 2 deletions av/packet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ class Packet:
is_keyframe: bool
is_corrupt: bool

def __init__(self, input=None): ...
def decode(self) -> list: ...
def __init__(self, input: int | None = None): ...
17 changes: 16 additions & 1 deletion av/video/frame.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
from typing import Any

from PIL import Image

from av.enum import EnumItem

from .plane import VideoPlane

class PictureType(EnumItem):
NONE: int
I: int
P: int
B: int
S: int
SI: int
SP: int
BI: int

class VideoFrame:
planes: tuple[VideoPlane]
width: int
Expand All @@ -10,7 +24,8 @@ class VideoFrame:
interlaced_frame: bool
pict_type: Any

def from_image(self, img: Any) -> VideoFrame: ...
def from_image(self, img: Image.Image) -> VideoFrame: ...
def to_image(self, **kwargs) -> Image.Image: ...
def __init__(
self, name: str, width: int = 0, height: int = 0, format: str = "yuv420p"
): ...
7 changes: 6 additions & 1 deletion av/video/stream.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
from av.packet import Packet
from av.stream import Stream

class VideoStream(Stream): ...
from .frame import VideoFrame

class VideoStream(Stream):
def encode(self, frame: VideoFrame | None = None) -> list[Packet]: ...
def decode(self, packet: Packet | None = None) -> list[VideoFrame]: ...

0 comments on commit da08233

Please sign in to comment.