Spaces:
Sleeping
Sleeping
Update gully_drs_core/video_utils.py
Browse files
gully_drs_core/video_utils.py
CHANGED
|
@@ -3,14 +3,16 @@ import tempfile
|
|
| 3 |
import shutil
|
| 4 |
|
| 5 |
def save_temp_video(uploaded_file):
|
| 6 |
-
|
| 7 |
-
if hasattr(uploaded_file, 'name')
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def get_video_properties(video_path):
|
| 16 |
cap = cv2.VideoCapture(video_path)
|
|
|
|
| 3 |
import shutil
|
| 4 |
|
| 5 |
def save_temp_video(uploaded_file):
|
| 6 |
+
# uploaded_file is expected to be the file path, not a file object
|
| 7 |
+
file_path = uploaded_file.name if hasattr(uploaded_file, 'name') else uploaded_file
|
| 8 |
+
|
| 9 |
+
# Open the file in binary mode to read its contents
|
| 10 |
+
with open(file_path, 'rb') as f:
|
| 11 |
+
# Create a temporary file
|
| 12 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as temp_video:
|
| 13 |
+
# Write the contents of the uploaded file to the temporary file
|
| 14 |
+
temp_video.write(f.read())
|
| 15 |
+
return temp_video.name
|
| 16 |
|
| 17 |
def get_video_properties(video_path):
|
| 18 |
cap = cv2.VideoCapture(video_path)
|