TheKnight115 commited on
Commit
215a6c6
·
verified ·
1 Parent(s): abdcbed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -40,11 +40,13 @@ def process_video(uploaded_file):
40
  total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) # Get the total number of frames
41
  frames = []
42
 
43
- # Create a Streamlit progress bar and text for percentage
44
  progress_bar = st.progress(0)
45
  progress_text = st.empty() # Placeholder for percentage text
 
46
 
47
  current_frame = 0
 
48
 
49
  while True:
50
  ret, frame = video.read()
@@ -65,6 +67,10 @@ def process_video(uploaded_file):
65
  progress_bar.progress(progress_percentage / 100) # Update the progress bar
66
  progress_text.text(f'Processing: {progress_percentage:.2f}%') # Update the percentage text
67
 
 
 
 
 
68
  video.release()
69
 
70
  # Create a video writer to save the processed frames
@@ -81,9 +87,14 @@ def process_video(uploaded_file):
81
  progress_bar.progress(100)
82
  progress_text.text('Processing: 100%')
83
  st.success('Video processing complete!')
 
 
 
 
84
 
85
- st.video(output_path) # Display the processed video
86
-
 
87
  # Create a download button for the processed video
88
  with open(output_path, 'rb') as f:
89
  video_bytes = f.read()
 
40
  total_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT)) # Get the total number of frames
41
  frames = []
42
 
43
+ # Create a Streamlit progress bar, text for percentage, and timer
44
  progress_bar = st.progress(0)
45
  progress_text = st.empty() # Placeholder for percentage text
46
+ timer_text = st.empty() # Placeholder for the timer
47
 
48
  current_frame = 0
49
+ start_time = time.time() # Start the timer
50
 
51
  while True:
52
  ret, frame = video.read()
 
67
  progress_bar.progress(progress_percentage / 100) # Update the progress bar
68
  progress_text.text(f'Processing: {progress_percentage:.2f}%') # Update the percentage text
69
 
70
+ # Calculate and display the elapsed time
71
+ elapsed_time = time.time() - start_time
72
+ timer_text.text(f'Elapsed Time: {elapsed_time:.2f} seconds') # Update the timer text
73
+
74
  video.release()
75
 
76
  # Create a video writer to save the processed frames
 
87
  progress_bar.progress(100)
88
  progress_text.text('Processing: 100%')
89
  st.success('Video processing complete!')
90
+
91
+ # Display the final elapsed time
92
+ final_elapsed_time = time.time() - start_time
93
+ timer_text.text(f'Total Elapsed Time: {final_elapsed_time:.2f} seconds')
94
 
95
+ # Display the processed video
96
+ st.video(output_path)
97
+
98
  # Create a download button for the processed video
99
  with open(output_path, 'rb') as f:
100
  video_bytes = f.read()