forked from PyAV-Org/PyAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
334 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,65 @@ | ||
from fractions import Fraction | ||
from numbers import Real | ||
from pathlib import Path | ||
from typing import Any, Iterator, Literal, overload | ||
|
||
from av import error, logging | ||
|
||
class Codec: | ||
name: str | ||
mode: Literal["r", "w"] | ||
|
||
frame_rates: list[Fraction] | None | ||
audio_rates: list[int] | None | ||
|
||
class CodecContext: | ||
name: str | ||
bit_rate: int | None | ||
width: int | ||
height: int | ||
pix_fmt: str | None | ||
sample_aspect_ratio: Fraction | None | ||
sample_rate: int | None | ||
channels: int | ||
extradata_size: int | ||
is_open: Literal[0, 1] | ||
is_encoder: Literal[0, 1] | ||
is_decoder: Literal[0, 1] | ||
|
||
class Stream: | ||
thread_type: Literal["NONE", "FRAME", "SLICE", "AUTO"] | ||
|
||
id: int | ||
profile: str | None | ||
codec_context: CodecContext | ||
|
||
index: int | ||
time_base: Fraction | None | ||
average_rate: Fraction | None | ||
base_rate: Fraction | None | ||
guessed_rate: Fraction | None | ||
|
||
start_time: int | None | ||
duration: int | None | ||
frames: int | ||
language: str | None | ||
|
||
# Defined by `av_get_media_type_string` at | ||
# https://ffmpeg.org/doxygen/6.0/libavutil_2utils_8c_source.html | ||
type: Literal["video", "audio", "data", "subtitle", "attachment"] | ||
|
||
# From `codec_context` | ||
name: str | ||
bit_rate: int | None | ||
width: int | ||
height: int | ||
pix_fmt: str | None | ||
sample_aspect_ratio: Fraction | None | ||
sample_rate: int | None | ||
channels: int | ||
extradata_size: int | ||
is_open: Literal[0, 1] | ||
is_encoder: Literal[0, 1] | ||
is_decoder: Literal[0, 1] | ||
|
||
def decode(self, packet=None): ... | ||
def encode(self, frame=None): ... | ||
|
||
class ContainerFormat: ... | ||
|
||
class StreamContainer: | ||
video: tuple[Stream, ...] | ||
audio: tuple[Stream, ...] | ||
subtitles: tuple[Stream, ...] | ||
data: tuple[Stream, ...] | ||
other: tuple[Stream, ...] | ||
|
||
def __init__(self) -> None: ... | ||
def add_stream(self, stream: Stream) -> None: ... | ||
def __len__(self) -> int: ... | ||
def __iter__(self) -> Iterator[Stream]: ... | ||
@overload | ||
def __getitem__(self, index: int) -> Stream: ... | ||
@overload | ||
def __getitem__(self, index: slice) -> list[Stream]: ... | ||
@overload | ||
def __getitem__(self, index: int | slice) -> Stream | list[Stream]: ... | ||
def get( | ||
self, | ||
*args: int | Stream | dict[str, int | tuple[int, ...]], | ||
**kwargs: int | tuple[int, ...], | ||
) -> list[Stream]: ... | ||
|
||
class Container: | ||
writeable: bool | ||
name: str | ||
metadata_encoding: str | ||
metadata_errors: str | ||
file: Any | ||
buffer_size: int | ||
input_was_opened: bool | ||
io_open: Any | ||
open_files: Any | ||
format: ContainerFormat | ||
options: dict[str, str] | ||
container_options: dict[str, str] | ||
stream_options: list[str] | ||
streams: StreamContainer | ||
duration: int | None | ||
metadata: dict[str, str] | ||
open_timeout: Real | None | ||
read_timeout: Real | None | ||
|
||
def __enter__(self) -> Container: ... | ||
def __exit__(self, exc_type, exc_val, exc_tb): ... | ||
def err_check(self, value: int) -> int: ... | ||
def set_timeout(self, timeout: Real | None) -> None: ... | ||
def start_timeout(self) -> None: ... | ||
|
||
class InputContainer(Container): | ||
bit_rate: int | ||
size: int | ||
|
||
def demux(self, *args, **kwargs): ... | ||
def decode(self, *args, **kwargs): ... | ||
|
||
class OutputContainer(Container): | ||
def start_encoding(self) -> None: ... | ||
from .container.input import InputContainer | ||
from .container.output import OutputContainer | ||
|
||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: str | Path, | ||
mode: Literal["r"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["w"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> OutputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r", "w"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer | OutputContainer: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from .plane import AudioPlane | ||
|
||
format_dtypes: dict[str, str] | ||
|
||
class AudioFrame: | ||
planes: tuple[AudioPlane] | ||
samples: int | ||
sample_rate: int | ||
rate: int | ||
|
||
def __init__( | ||
self, | ||
format: str = "s16", | ||
layout: str = "stereo", | ||
samples: int = 0, | ||
align: int = 1, | ||
): ... | ||
def to_ndarray(self): ... | ||
@staticmethod | ||
def from_ndarray( | ||
array, format: str = "s16", layout: str = "stereo" | ||
) -> AudioFrame: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class AudioPlane: | ||
buffer_size: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,3 @@ | ||
from numbers import Real | ||
from pathlib import Path | ||
from typing import Any, Literal, overload | ||
|
||
from av import InputContainer, OutputContainer | ||
|
||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: str | Path, | ||
mode: Literal["r"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["w"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> OutputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r", "w"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer | OutputContainer: ... | ||
from .core import Container, open | ||
from .input import InputContainer | ||
from .output import OutputContainer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
from numbers import Real | ||
from pathlib import Path | ||
from typing import Any, Iterator, Literal, overload | ||
|
||
from .input import InputContainer | ||
from .output import OutputContainer | ||
from .streams import StreamContainer | ||
|
||
class Container: | ||
writeable: bool | ||
name: str | ||
metadata_encoding: str | ||
metadata_errors: str | ||
file: Any | ||
buffer_size: int | ||
input_was_opened: bool | ||
io_open: Any | ||
open_files: Any | ||
format: str | None | ||
options: dict[str, str] | ||
container_options: dict[str, str] | ||
stream_options: list[str] | ||
streams: StreamContainer | ||
duration: int | None | ||
metadata: dict[str, str] | ||
open_timeout: Real | None | ||
read_timeout: Real | None | ||
|
||
def __enter__(self) -> Container: ... | ||
def __exit__(self, exc_type, exc_val, exc_tb): ... | ||
def err_check(self, value: int) -> int: ... | ||
def set_timeout(self, timeout: Real | None) -> None: ... | ||
def start_timeout(self) -> None: ... | ||
|
||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: str | Path, | ||
mode: Literal["r"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["w"], | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> OutputContainer: ... | ||
@overload | ||
def open( | ||
file: Any, | ||
mode: Literal["r", "w"] | None = None, | ||
format: str | None = None, | ||
options: dict[str, str] | None = None, | ||
container_options: dict[str, str] | None = None, | ||
stream_options: list[str] | None = None, | ||
metadata_encoding: str = "utf-8", | ||
metadata_errors: str = "strict", | ||
buffer_size: int = 32768, | ||
timeout=Real | None | tuple[Real | None, Real | None], | ||
io_open=None, | ||
) -> InputContainer | OutputContainer: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .core import Container | ||
from .streams import Stream | ||
|
||
class InputContainer(Container): | ||
bit_rate: int | ||
size: int | ||
|
||
def demux(self, *args, **kwargs): ... | ||
def decode(self, *args, **kwargs): ... | ||
def seek( | ||
self, | ||
offset: int, | ||
*, | ||
whence: str = "time", | ||
backward: bool = True, | ||
any_frame: bool = False, | ||
stream: Stream | None = None, | ||
unsupported_frame_offset: bool = False, | ||
unsupported_byte_offset: bool = False, | ||
) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .core import Container | ||
|
||
class OutputContainer(Container): | ||
def start_encoding(self) -> None: ... |
Oops, something went wrong.