Spaces:
Sleeping
Sleeping
Add streamlit-webrtc sample
Browse files- app.py +22 -2
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,4 +1,24 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from streamlit_webrtc import webrtc_streamer
|
3 |
+
import av
|
4 |
|
5 |
+
|
6 |
+
flip = st.checkbox("Flip")
|
7 |
+
|
8 |
+
|
9 |
+
def video_frame_callback(frame):
|
10 |
+
img = frame.to_ndarray(format="bgr24")
|
11 |
+
|
12 |
+
flipped = img[::-1,:,:] if flip else img
|
13 |
+
|
14 |
+
return av.VideoFrame.from_ndarray(flipped, format="bgr24")
|
15 |
+
|
16 |
+
|
17 |
+
webrtc_streamer(
|
18 |
+
key="sample",
|
19 |
+
video_frame_callback=video_frame_callback,
|
20 |
+
media_stream_constraints={"video": True, "audio": False},
|
21 |
+
rtc_configuration={ # Add this config
|
22 |
+
"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]
|
23 |
+
}
|
24 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
streamlit-webrtc
|