ju0im6bt6 commited on
Commit
c723091
·
verified ·
1 Parent(s): bb18a64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
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
- webrtc = WebRTC(
23
  label="Webcam Stream",
24
- mode="send-receive",
25
  modality="video",
26
  rtc_configuration=rtc_configuration,
27
  )
28
 
29
- # Stream video and apply the flip filter
30
- webrtc.process(
 
 
 
 
 
 
 
 
31
  fn=flip_vertically,
32
- inputs=[webrtc],
33
- outputs=[webrtc],
34
- time_limit=90, # Limit processing time per user
35
- every=0.1, # Capture and process frames every 0.1 seconds for real-time effect
 
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