Spaces:
Paused

COLTO50 commited on
Commit
ea06f6f
·
verified ·
1 Parent(s): 2115ac4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -114,25 +114,35 @@ def save_uploaded_file(uploaded_file):
114
  save_path.mkdir(exist_ok=True)
115
  file_path = save_path / uploaded_file.name
116
 
117
- with st.progress("Uploading file...") as progress_bar:
118
- with file_path.open("wb") as f:
119
- total_size = uploaded_file.size
120
- chunk_size = 1024 * 1024 # 1MB chunks
121
- uploaded_size = 0
122
- for chunk in uploaded_file.chunks(chunk_size=chunk_size):
123
- f.write(chunk)
124
- uploaded_size += len(chunk)
125
- progress = min(uploaded_size / total_size, 1.0)
126
- progress_bar.progress(progress)
 
 
 
 
 
 
 
 
 
 
127
  return True
128
  except Exception as e:
129
- st.error(f"Error saving file: {e}")
130
  return False
131
 
132
  def get_uploaded_videos():
133
  video_dir = Path("uploaded_videos")
134
  video_dir.mkdir(exist_ok=True)
135
- return [f for f in video_dir.glob("*") if f.suffix.lower() in ['.mp4', '.mkv', '.avi', '.mov']]
136
 
137
  def generate_thumbnail(video_path):
138
  video = cv2.VideoCapture(str(video_path))
@@ -149,7 +159,7 @@ def generate_thumbnail(video_path):
149
  def main():
150
  st.markdown("<h1 style='text-align: center;'>UltraVideoSpace</h1>", unsafe_allow_html=True)
151
 
152
- uploaded_file = st.file_uploader("", type=['mp4', 'mkv', 'avi', 'mov'], key="video_uploader")
153
 
154
  upload_placeholder = st.empty()
155
  with upload_placeholder.container():
@@ -157,7 +167,8 @@ def main():
157
  <div class="upload-zone">
158
  <h3>Drag and drop your video here</h3>
159
  <p>or click to select files</p>
160
- <p>Supported formats: MP4, MKV, AVI, MOV</p>
 
161
  </div>
162
  """, unsafe_allow_html=True)
163
 
 
114
  save_path.mkdir(exist_ok=True)
115
  file_path = save_path / uploaded_file.name
116
 
117
+ total_size = uploaded_file.size
118
+ chunk_size = 1024 * 1024 # 1MB chunks
119
+ uploaded_size = 0
120
+
121
+ progress_bar = st.progress(0)
122
+ status_text = st.empty()
123
+
124
+ with file_path.open("wb") as f:
125
+ while True:
126
+ chunk = uploaded_file.read(chunk_size)
127
+ if not chunk:
128
+ break
129
+ f.write(chunk)
130
+ uploaded_size += len(chunk)
131
+ progress = min(uploaded_size / total_size, 1.0)
132
+ progress_bar.progress(int(progress * 100))
133
+ status_text.text(f"Uploading... {int(progress * 100)}%")
134
+
135
+ progress_bar.empty()
136
+ status_text.empty()
137
  return True
138
  except Exception as e:
139
+ st.error(f"Error saving file: {str(e)}")
140
  return False
141
 
142
  def get_uploaded_videos():
143
  video_dir = Path("uploaded_videos")
144
  video_dir.mkdir(exist_ok=True)
145
+ return [f for f in video_dir.glob("*") if f.suffix.lower() in ['.mp4', '.mkv', '.avi', '.mov', '.mpeg4']]
146
 
147
  def generate_thumbnail(video_path):
148
  video = cv2.VideoCapture(str(video_path))
 
159
  def main():
160
  st.markdown("<h1 style='text-align: center;'>UltraVideoSpace</h1>", unsafe_allow_html=True)
161
 
162
+ uploaded_file = st.file_uploader("", type=['mp4', 'mkv', 'avi', 'mov', 'mpeg4'], key="video_uploader")
163
 
164
  upload_placeholder = st.empty()
165
  with upload_placeholder.container():
 
167
  <div class="upload-zone">
168
  <h3>Drag and drop your video here</h3>
169
  <p>or click to select files</p>
170
+ <p>Supported formats: MP4, MKV, AVI, MOV, MPEG4</p>
171
+ <p>No file size limit</p>
172
  </div>
173
  """, unsafe_allow_html=True)
174