Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,20 +19,29 @@ with gr.Blocks() as demo:
|
|
19 |
gr.HTML("<h1 style='text-align: center'>Real-Time Webcam Stream with FastRTC</h1>")
|
20 |
|
21 |
# WebRTC component for video streaming
|
22 |
-
|
23 |
label="Webcam Stream",
|
24 |
-
mode="send
|
25 |
modality="video",
|
26 |
rtc_configuration=rtc_configuration,
|
27 |
)
|
28 |
|
29 |
-
#
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
fn=flip_vertically,
|
32 |
-
inputs=[
|
33 |
-
outputs=[
|
34 |
-
|
35 |
-
|
|
|
36 |
)
|
37 |
|
38 |
# Launch the app
|
|
|
19 |
gr.HTML("<h1 style='text-align: center'>Real-Time Webcam Stream with FastRTC</h1>")
|
20 |
|
21 |
# WebRTC component for video streaming
|
22 |
+
webrtc_input = WebRTC(
|
23 |
label="Webcam Stream",
|
24 |
+
mode="send",
|
25 |
modality="video",
|
26 |
rtc_configuration=rtc_configuration,
|
27 |
)
|
28 |
|
29 |
+
# Output component to display processed video
|
30 |
+
webrtc_output = WebRTC(
|
31 |
+
label="Processed Stream",
|
32 |
+
mode="receive",
|
33 |
+
modality="video",
|
34 |
+
rtc_configuration=rtc_configuration,
|
35 |
+
)
|
36 |
+
|
37 |
+
# Process video frames in real time using change event
|
38 |
+
webrtc_input.change(
|
39 |
fn=flip_vertically,
|
40 |
+
inputs=[webrtc_input],
|
41 |
+
outputs=[webrtc_output],
|
42 |
+
_js="() => {}", # Ensures continuous streaming
|
43 |
+
queue=True,
|
44 |
+
every=0.1, # Process frames every 0.1 seconds for real-time effect
|
45 |
)
|
46 |
|
47 |
# Launch the app
|