File tree Expand file tree Collapse file tree 6 files changed +39
-29
lines changed
Expand file tree Collapse file tree 6 files changed +39
-29
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,21 @@ from .format import AudioFormat
77from .frame import AudioFrame
88from .layout import AudioLayout
99
10+ class _Format :
11+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioFormat : ...
12+ def __set__ (self , instance : object , value : AudioFormat | str ) -> None : ...
13+
14+ class _Layout :
15+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioLayout : ...
16+ def __set__ (self , instance : object , value : AudioLayout | str ) -> None : ...
17+
1018class AudioCodecContext (CodecContext ):
1119 frame_size : int
1220 sample_rate : int
1321 rate : int
1422 type : Literal ["audio" ]
15-
16- @property
17- def format (self ) -> AudioFormat : ...
18- @format .setter
19- def format (self , value : AudioFormat | str ) -> None : ...
20- @property
21- def layout (self ) -> AudioLayout : ...
22- @layout .setter
23- def layout (self , value : AudioLayout | str ) -> None : ...
23+ format : _Format
24+ layout : _Layout
2425 @property
2526 def channels (self ) -> int : ...
2627 def encode (self , frame : AudioFrame | None = None ) -> list [Packet ]: ...
Original file line number Diff line number Diff line change @@ -17,13 +17,21 @@ _SupportedNDarray = Union[
1717 np .ndarray [Any , np .dtype [np .uint8 ]], # u1
1818]
1919
20+ class _Format :
21+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioFormat : ...
22+ def __set__ (self , instance : object , value : AudioFormat | str ) -> None : ...
23+
24+ class _Layout :
25+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioLayout : ...
26+ def __set__ (self , instance : object , value : AudioLayout | str ) -> None : ...
27+
2028class AudioFrame (Frame ):
2129 planes : tuple [AudioPlane , ...]
2230 samples : int
2331 sample_rate : int
2432 rate : int
25- format : AudioFormat
26- layout : AudioLayout
33+ format : _Format
34+ layout : _Layout
2735
2836 def __init__ (
2937 self ,
Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ from .format import AudioFormat
88from .frame import AudioFrame
99from .layout import AudioLayout
1010
11+ class _Format :
12+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioFormat : ...
13+ def __set__ (self , instance : object , value : AudioFormat | str ) -> None : ...
14+
15+ class _Layout :
16+ def __get__ (self , i : object | None , owner : type | None = None ) -> AudioLayout : ...
17+ def __set__ (self , instance : object , value : AudioLayout | str ) -> None : ...
18+
1119class AudioStream (Stream ):
1220 codec_context : AudioCodecContext
1321 # From codec context
@@ -17,14 +25,7 @@ class AudioStream(Stream):
1725 rate : int
1826 channels : int
1927 type : Literal ["audio" ]
20-
21- @property
22- def format (self ) -> AudioFormat : ...
23- @format .setter
24- def format (self , value : AudioFormat | str ) -> None : ...
25- @property
26- def layout (self ) -> AudioLayout : ...
27- @layout .setter
28- def layout (self , value : AudioLayout | str ) -> None : ...
28+ format : _Format
29+ layout : _Layout
2930 def encode (self , frame : AudioFrame | None = None ) -> list [Packet ]: ...
3031 def decode (self , packet : Packet | None = None ) -> list [AudioFrame ]: ...
Original file line number Diff line number Diff line change @@ -34,8 +34,8 @@ class Graph:
3434 self ,
3535 template : AudioStream | None = None ,
3636 sample_rate : int | None = None ,
37- format : AudioFormat | None = None ,
38- layout : AudioLayout | None = None ,
37+ format : AudioFormat | str | None = None ,
38+ layout : AudioLayout | str | None = None ,
3939 channels : int | None = None ,
4040 name : str | None = None ,
4141 time_base : Fraction | None = None ,
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ def test_encoder_extradata(self):
139139 assert ctx .extradata_size == 3
140140
141141 def test_encoder_pix_fmt (self ):
142- ctx = av .codec .Codec ("h264" , "w" ).create ()
142+ ctx = av .codec .Codec ("h264" , "w" ).create ("video" )
143143
144144 # valid format
145145 ctx .pix_fmt = "yuv420p"
@@ -429,8 +429,8 @@ def _audio_encoding(
429429
430430 ctx .time_base = Fraction (1 ) / sample_rate
431431 ctx .sample_rate = sample_rate
432- ctx .format = sample_fmt # type: ignore
433- ctx .layout = channel_layout # type: ignore
432+ ctx .format = sample_fmt
433+ ctx .layout = channel_layout
434434
435435 ctx .open ()
436436
@@ -463,8 +463,8 @@ def _audio_encoding(
463463
464464 ctx = Codec (codec_name , "r" ).create ("audio" )
465465 ctx .sample_rate = sample_rate
466- ctx .format = sample_fmt # type: ignore
467- ctx .layout = channel_layout # type: ignore
466+ ctx .format = sample_fmt
467+ ctx .layout = channel_layout
468468 ctx .open ()
469469
470470 result_samples = 0
Original file line number Diff line number Diff line change @@ -196,8 +196,8 @@ def test_transcode(self) -> None:
196196
197197 ctx = stream .codec_context
198198 ctx .sample_rate = sample_rate
199- stream .format = sample_fmt # type: ignore
200- ctx .layout = channel_layout # type: ignore
199+ stream .format = sample_fmt
200+ ctx .layout = channel_layout
201201
202202 with av .open (
203203 fate_suite ("audio-reference/chorusnoise_2ch_44kHz_s16.wav" )
You can’t perform that action at this time.
0 commit comments