Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,6 +48,13 @@ def process_video(video_path):
|
|
48 |
|
49 |
cap.release()
|
50 |
out.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
return output_path
|
52 |
|
53 |
# Streamlit interface
|
@@ -69,7 +76,7 @@ with right_column:
|
|
69 |
uploaded_video = st.file_uploader("Or upload your own video", type=["mp4", "avi", "mov"])
|
70 |
|
71 |
if uploaded_video is not None:
|
72 |
-
video_path = uploaded_video.name
|
73 |
with open(video_path, 'wb') as f:
|
74 |
f.write(uploaded_video.getbuffer())
|
75 |
st.success(f"Uploaded {uploaded_video.name}")
|
@@ -78,8 +85,10 @@ with right_column:
|
|
78 |
|
79 |
if st.button("Process Video"):
|
80 |
output_video = process_video(video_path)
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
48 |
|
49 |
cap.release()
|
50 |
out.release()
|
51 |
+
|
52 |
+
# Double-check that the file was saved
|
53 |
+
if os.path.exists(output_path):
|
54 |
+
st.success(f"Video successfully processed and saved to {output_path}")
|
55 |
+
else:
|
56 |
+
st.error("Failed to save the processed video.")
|
57 |
+
|
58 |
return output_path
|
59 |
|
60 |
# Streamlit interface
|
|
|
76 |
uploaded_video = st.file_uploader("Or upload your own video", type=["mp4", "avi", "mov"])
|
77 |
|
78 |
if uploaded_video is not None:
|
79 |
+
video_path = os.path.join(os.getcwd(), uploaded_video.name)
|
80 |
with open(video_path, 'wb') as f:
|
81 |
f.write(uploaded_video.getbuffer())
|
82 |
st.success(f"Uploaded {uploaded_video.name}")
|
|
|
85 |
|
86 |
if st.button("Process Video"):
|
87 |
output_video = process_video(video_path)
|
88 |
+
if output_video and os.path.exists(output_video):
|
89 |
+
left_column.video(output_video) # Display video in the left column
|
90 |
+
left_column.write("Download the processed video:")
|
91 |
+
with open(output_video, "rb") as video_file:
|
92 |
+
left_column.download_button("Download", video_file, "output.mp4")
|
93 |
+
else:
|
94 |
+
st.error("There was an issue processing the video. Please try again.")
|