Kunal7 commited on
Commit
35ca70f
·
1 Parent(s): 74db211

Update pages/1_📷️_Live_Stream.py

Browse files
Files changed (1) hide show
  1. pages/1_📷️_Live_Stream.py +17 -7
pages/1_📷️_Live_Stream.py CHANGED
@@ -33,11 +33,12 @@ live_process_frame = ProcessFrame(thresholds=thresholds, flip_frame=True)
33
  pose = get_mediapipe_pose()
34
 
35
 
36
- output_video_file = f'output_live.flv'
 
37
 
38
- if os.path.exists(output_video_file):
39
- os.remove(output_video_file)
40
 
 
41
 
42
  def video_frame_callback(frame: av.VideoFrame):
43
  frame = frame.to_ndarray(format="rgb24") # Decode and get RGB frame
@@ -53,19 +54,28 @@ ctx = webrtc_streamer(
53
  key="Squats-pose-analysis",
54
  video_frame_callback=video_frame_callback,
55
  rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}, # Add this config
56
- media_stream_constraints={"video": {"width": {"min":800, "max": 1280}}, "audio": False},
57
  video_html_attrs=VideoHTMLAttributes(autoPlay=True, controls=False, muted=False),
58
  out_recorder_factory=out_recorder_factory
59
  )
60
 
61
 
 
 
62
  if os.path.exists(output_video_file):
63
  with open(output_video_file, 'rb') as op_vid:
64
- st.download_button('Download Video', data = op_vid, file_name='output_live.flv')
65
 
 
 
 
 
 
 
 
 
 
66
 
67
-
68
-
69
 
70
 
71
 
 
33
  pose = get_mediapipe_pose()
34
 
35
 
36
+ if 'download' not in st.session_state:
37
+ st.session_state['download'] = False
38
 
39
+ output_video_file = f'output_live.flv'
 
40
 
41
+
42
 
43
  def video_frame_callback(frame: av.VideoFrame):
44
  frame = frame.to_ndarray(format="rgb24") # Decode and get RGB frame
 
54
  key="Squats-pose-analysis",
55
  video_frame_callback=video_frame_callback,
56
  rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}, # Add this config
57
+ media_stream_constraints={"video": {"width": {'min':480, 'ideal':480}}, "audio": False},
58
  video_html_attrs=VideoHTMLAttributes(autoPlay=True, controls=False, muted=False),
59
  out_recorder_factory=out_recorder_factory
60
  )
61
 
62
 
63
+ download_button = st.empty()
64
+
65
  if os.path.exists(output_video_file):
66
  with open(output_video_file, 'rb') as op_vid:
67
+ download = download_button.download_button('Download Video', data = op_vid, file_name='output_live.flv')
68
 
69
+ if download:
70
+ st.session_state['download'] = True
71
+
72
+
73
+
74
+ if os.path.exists(output_video_file) and st.session_state['download']:
75
+ os.remove(output_video_file)
76
+ st.session_state['download'] = False
77
+ download_button.empty()
78
 
 
 
79
 
80
 
81