streamlit-webrtc 0.62.4__py3-none-any.whl → 0.63.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- streamlit_webrtc/__init__.py +15 -2
- streamlit_webrtc/factory.py +35 -1
- streamlit_webrtc/frontend/dist/assets/{index-DWHlEvv5.js → index-Cn4hJFys.js} +20 -20
- streamlit_webrtc/frontend/dist/index.html +1 -1
- streamlit_webrtc/source.py +61 -0
- {streamlit_webrtc-0.62.4.dist-info → streamlit_webrtc-0.63.1.dist-info}/METADATA +2 -2
- {streamlit_webrtc-0.62.4.dist-info → streamlit_webrtc-0.63.1.dist-info}/RECORD +9 -9
- {streamlit_webrtc-0.62.4.dist-info → streamlit_webrtc-0.63.1.dist-info}/WHEEL +0 -0
- {streamlit_webrtc-0.62.4.dist-info → streamlit_webrtc-0.63.1.dist-info}/licenses/LICENSE +0 -0
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
7
7
|
<meta name="theme-color" content="#000000" />
|
8
8
|
<meta name="description" content="Streamlit WebRTC Component" />
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
9
|
+
<script type="module" crossorigin src="./assets/index-Cn4hJFys.js"></script>
|
10
10
|
</head>
|
11
11
|
<body>
|
12
12
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
streamlit_webrtc/source.py
CHANGED
@@ -12,6 +12,8 @@ logger = logging.getLogger(__name__)
|
|
12
12
|
|
13
13
|
# Copied from https://github.com/aiortc/aiortc/blob/main/src/aiortc/mediastreams.py
|
14
14
|
AUDIO_PTIME = 0.020 # 20ms audio packetization
|
15
|
+
AUDIO_SAMPLE_RATE = 48000
|
16
|
+
AUDIO_TIME_BASE = fractions.Fraction(1, AUDIO_SAMPLE_RATE)
|
15
17
|
VIDEO_CLOCK_RATE = 90000
|
16
18
|
VIDEO_TIME_BASE = fractions.Fraction(1, VIDEO_CLOCK_RATE)
|
17
19
|
|
@@ -24,6 +26,10 @@ VideoSourceCallback = Callable[
|
|
24
26
|
[int, fractions.Fraction], av.VideoFrame
|
25
27
|
] # (pts, time_base) -> frame
|
26
28
|
|
29
|
+
AudioSourceCallback = Callable[
|
30
|
+
[int, fractions.Fraction], av.AudioFrame
|
31
|
+
] # (pts, time_base) -> frame
|
32
|
+
|
27
33
|
|
28
34
|
class VideoSourceTrack(MediaStreamTrack):
|
29
35
|
def __init__(self, callback: VideoSourceCallback, fps: Union[int, float]) -> None:
|
@@ -65,6 +71,61 @@ class VideoSourceTrack(MediaStreamTrack):
|
|
65
71
|
logger.error(
|
66
72
|
"VideoSourceCallbackTrack: Video frame callback raised an exception: %s", # noqa: E501
|
67
73
|
exc,
|
74
|
+
exc_info=True,
|
75
|
+
)
|
76
|
+
raise
|
77
|
+
|
78
|
+
frame.pts = pts
|
79
|
+
frame.time_base = time_base
|
80
|
+
return frame
|
81
|
+
|
82
|
+
|
83
|
+
class AudioSourceTrack(MediaStreamTrack):
|
84
|
+
def __init__(
|
85
|
+
self,
|
86
|
+
callback: AudioSourceCallback,
|
87
|
+
sample_rate: int = AUDIO_SAMPLE_RATE,
|
88
|
+
ptime: float = AUDIO_PTIME,
|
89
|
+
) -> None:
|
90
|
+
super().__init__()
|
91
|
+
self.kind = "audio"
|
92
|
+
self._callback = callback
|
93
|
+
self._sample_rate = sample_rate
|
94
|
+
self._ptime = ptime
|
95
|
+
self._samples_per_frame = int(self._sample_rate * self._ptime)
|
96
|
+
self._started_at: Optional[float] = None
|
97
|
+
self._pts: Optional[int] = None
|
98
|
+
|
99
|
+
async def recv(self) -> av.frame.Frame:
|
100
|
+
if self.readyState != "live":
|
101
|
+
raise MediaStreamError
|
102
|
+
|
103
|
+
if self._started_at is None or self._pts is None:
|
104
|
+
self._started_at = time.monotonic()
|
105
|
+
self._pts = 0
|
106
|
+
|
107
|
+
frame = self._call_callback(self._pts, AUDIO_TIME_BASE)
|
108
|
+
else:
|
109
|
+
self._pts += self._samples_per_frame
|
110
|
+
|
111
|
+
frame = self._call_callback(self._pts, AUDIO_TIME_BASE)
|
112
|
+
|
113
|
+
wait = self._started_at + (self._pts / self._sample_rate) - time.monotonic()
|
114
|
+
if wait < 0:
|
115
|
+
logger.warning("AudioSourceTrack: Audio frame callback is too slow.")
|
116
|
+
wait = 0
|
117
|
+
await asyncio.sleep(wait)
|
118
|
+
|
119
|
+
return frame
|
120
|
+
|
121
|
+
def _call_callback(self, pts: int, time_base: fractions.Fraction) -> av.AudioFrame:
|
122
|
+
try:
|
123
|
+
frame = self._callback(pts, time_base)
|
124
|
+
except Exception as exc:
|
125
|
+
logger.error(
|
126
|
+
"AudioSourceTrack: Audio frame callback raised an exception: %s",
|
127
|
+
exc,
|
128
|
+
exc_info=True,
|
68
129
|
)
|
69
130
|
raise
|
70
131
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: streamlit-webrtc
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.63.1
|
4
4
|
Summary: Real-time video and audio processing on Streamlit
|
5
5
|
Project-URL: Repository, https://github.com/whitphx/streamlit-webrtc
|
6
6
|
Author-email: "Yuichiro Tachibana (Tsuchiya)" <t.yic.yt@gmail.com>
|
7
7
|
License-Expression: MIT
|
8
8
|
License-File: LICENSE
|
9
9
|
Requires-Python: !=3.9.7,>=3.9
|
10
|
-
Requires-Dist: aioice>=0.10.
|
10
|
+
Requires-Dist: aioice>=0.10.1
|
11
11
|
Requires-Dist: aiortc>=1.11.0
|
12
12
|
Requires-Dist: packaging>=20.0
|
13
13
|
Requires-Dist: streamlit>=0.89.0
|
@@ -1,11 +1,11 @@
|
|
1
|
-
streamlit_webrtc/__init__.py,sha256=
|
1
|
+
streamlit_webrtc/__init__.py,sha256=dzw8DtZ0D_FAXPeS7qT7QaKPTcxp9XAekpmcthwjF3I,2465
|
2
2
|
streamlit_webrtc/_compat.py,sha256=AVRcUGdgWDQcCE7-ufhGr6Hb5P6EHLgejUAA72ArJmg,4384
|
3
3
|
streamlit_webrtc/component.py,sha256=pixNqGXrTlogxXjXx6fSgMx2xPo0dj2fsXKenvWeqQk,28269
|
4
4
|
streamlit_webrtc/components_callbacks.py,sha256=tdrj2TlV8qcexFEdjm4PVkz8JwHffo4A8imoXOtjNHA,2401
|
5
5
|
streamlit_webrtc/config.py,sha256=yKFIVjIoX2F62_G2qcDrNYm2Qe_qx1E9E0YqAnAibMo,5544
|
6
6
|
streamlit_webrtc/credentials.py,sha256=fTs-DhUhScK8m7OEfkgTMw7pKXnS9QNpjtJAvR9oIzs,4619
|
7
7
|
streamlit_webrtc/eventloop.py,sha256=AFmxGlRRxVdl0cTS9pKpRZR2Mnq6v6DgudVZZ425IVw,1333
|
8
|
-
streamlit_webrtc/factory.py,sha256=
|
8
|
+
streamlit_webrtc/factory.py,sha256=4iKhb_g0wBO1YRoyCmdqIYwkNXODt4f9KbKxni5mQ0s,7927
|
9
9
|
streamlit_webrtc/mix.py,sha256=Uh9gJviP3VLxwBQ-i3RftJ8GQ5qDPGqJKgm2M-vQYo4,8775
|
10
10
|
streamlit_webrtc/models.py,sha256=3sKVjCFgX-eQ7nlMHGWxzR9ohdstxUSZaiOHjyDAHVQ,6308
|
11
11
|
streamlit_webrtc/process.py,sha256=i1bSoyIAccKCKmYGnrYLq0ElPFND_5SsY1u91NY-B48,7878
|
@@ -15,11 +15,11 @@ streamlit_webrtc/relay.py,sha256=2K2h0uNz50ARUOScYZPYlEmZb0uAi0agaYxI9z3mLeI,896
|
|
15
15
|
streamlit_webrtc/server.py,sha256=5o9E2MRIPoS18lfGPJkyhbd23RWyTwblNVVuAA2kKrA,1489
|
16
16
|
streamlit_webrtc/session_info.py,sha256=V1EdzD2I8dWANXdC84EKSz8XgPM-zugtkYsb4hJm8Qo,2313
|
17
17
|
streamlit_webrtc/shutdown.py,sha256=PUjMoNZcTRGzZCooCmjWARpeVs5EG_9JXAf1Iay7dBM,2353
|
18
|
-
streamlit_webrtc/source.py,sha256
|
18
|
+
streamlit_webrtc/source.py,sha256=-bcvQYMyXcrhnsQNL3VlHwLT4KGjJ4jIZcPLKrbczZM,4215
|
19
19
|
streamlit_webrtc/webrtc.py,sha256=WzgydYm3Xhoi5c1QHNLc_GiF_E0aGC5ynzmxeAbtJCw,29900
|
20
|
-
streamlit_webrtc/frontend/dist/index.html,sha256=
|
21
|
-
streamlit_webrtc/frontend/dist/assets/index-
|
22
|
-
streamlit_webrtc-0.
|
23
|
-
streamlit_webrtc-0.
|
24
|
-
streamlit_webrtc-0.
|
25
|
-
streamlit_webrtc-0.
|
20
|
+
streamlit_webrtc/frontend/dist/index.html,sha256=9Ld6LBoaaTi2Kis9PNJzVYEXTr4HZCrzLdRPjFcV5Rc,527
|
21
|
+
streamlit_webrtc/frontend/dist/assets/index-Cn4hJFys.js,sha256=RCkqQD2BlksGpCz-hYmK9wpoLII2VMux8x7unbw6uYA,589981
|
22
|
+
streamlit_webrtc-0.63.1.dist-info/METADATA,sha256=3EHTSFeXJv1Pm7T5bXCChckWpahF_FHvwAHEnHcIjlE,18288
|
23
|
+
streamlit_webrtc-0.63.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
24
|
+
streamlit_webrtc-0.63.1.dist-info/licenses/LICENSE,sha256=pwccNHVA7r4rYofGlMU10aKEU90GLUlQr8uY80PR0NQ,1081
|
25
|
+
streamlit_webrtc-0.63.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|