Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -50,22 +50,24 @@ class CustomTheme(Base):
|
|
50 |
custom_theme = CustomTheme()
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
53 |
-
print(f"Received object type: {type(uploaded_file)}") # Debug: Check the object type
|
54 |
if uploaded_file is None:
|
55 |
return None # Handle cases where no file was uploaded
|
56 |
-
|
57 |
-
print(f"File name: {uploaded_file.name}") # Debug: Print file name
|
58 |
upload_dir = "uploaded_videos"
|
59 |
os.makedirs(upload_dir, exist_ok=True)
|
60 |
file_path = os.path.join(upload_dir, uploaded_file.name)
|
61 |
|
62 |
-
#
|
63 |
with open(file_path, "wb") as f:
|
64 |
-
f.write(uploaded_file.
|
|
|
|
|
65 |
|
|
|
66 |
return file_path
|
67 |
|
68 |
|
|
|
69 |
def display_results(video_url, video_file, description):
|
70 |
"""Process video from URL or file upload and return the results."""
|
71 |
final_clip_path = None
|
|
|
50 |
custom_theme = CustomTheme()
|
51 |
|
52 |
def save_uploaded_file(uploaded_file):
|
|
|
53 |
if uploaded_file is None:
|
54 |
return None # Handle cases where no file was uploaded
|
55 |
+
|
|
|
56 |
upload_dir = "uploaded_videos"
|
57 |
os.makedirs(upload_dir, exist_ok=True)
|
58 |
file_path = os.path.join(upload_dir, uploaded_file.name)
|
59 |
|
60 |
+
# Save the temporary file to a new location
|
61 |
with open(file_path, "wb") as f:
|
62 |
+
f.write(uploaded_file.file.read()) # Write file content to disk
|
63 |
+
f.flush()
|
64 |
+
os.fsync(f.fileno()) # Ensure all file data is flushed to disk
|
65 |
|
66 |
+
print(f"File saved to {file_path}, size: {os.path.getsize(file_path)} bytes") # Debugging
|
67 |
return file_path
|
68 |
|
69 |
|
70 |
+
|
71 |
def display_results(video_url, video_file, description):
|
72 |
"""Process video from URL or file upload and return the results."""
|
73 |
final_clip_path = None
|