-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathtest_codec.py
More file actions
91 lines (67 loc) · 2.29 KB
/
test_codec.py
File metadata and controls
91 lines (67 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import pytest
from av import AudioFormat, Codec, VideoFormat, codecs_available
from av.codec.codec import UnknownCodecError
def test_codec_bogus() -> None:
with pytest.raises(UnknownCodecError):
Codec("bogus123")
with pytest.raises(UnknownCodecError):
Codec("bogus123", "w")
def test_codec_mpeg4_decoder() -> None:
c = Codec("mpeg4")
assert c.name == "mpeg4"
assert c.long_name == "MPEG-4 part 2"
assert c.type == "video"
assert c.id in (12, 13)
assert c.is_decoder
assert not c.is_encoder
assert c.delay
assert c.audio_formats is None and c.audio_rates is None
# formats = c.video_formats
# assert formats
# assert isinstance(formats[0], VideoFormat)
# assert any(f.name == "yuv420p" for f in formats)
assert c.frame_rates is None
def test_codec_mpeg4_encoder() -> None:
c = Codec("mpeg4", "w")
assert c.name == "mpeg4"
assert c.long_name == "MPEG-4 part 2"
assert c.type == "video"
assert c.id in (12, 13)
assert c.is_encoder
assert not c.is_decoder
assert c.delay
assert c.audio_formats is None and c.audio_rates is None
formats = c.video_formats
assert formats
assert isinstance(formats[0], VideoFormat)
assert any(f.name == "yuv420p" for f in formats)
assert c.frame_rates is None
def test_codec_opus_decoder() -> None:
c = Codec("opus")
assert c.name == "opus"
assert c.long_name == "Opus"
assert c.type == "audio"
assert c.is_decoder
assert not c.is_encoder
assert c.delay
assert c.audio_formats is None and c.audio_rates is None
assert c.video_formats is None and c.frame_rates is None
def test_codec_opus_encoder() -> None:
c = Codec("opus", "w")
assert c.name in ("opus", "libopus")
assert c.canonical_name == "opus"
assert c.long_name in ("Opus", "libopus Opus")
assert c.type == "audio"
assert c.is_encoder
assert not c.is_decoder
assert c.delay
# audio
formats = c.audio_formats
assert formats
assert isinstance(formats[0], AudioFormat)
assert any(f.name in ("flt", "fltp") for f in formats)
assert c.audio_rates is not None
assert 48000 in c.audio_rates
assert c.video_formats is None and c.frame_rates is None
def test_codecs_available() -> None:
assert codecs_available