Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,8 +30,22 @@ def get_video_base64(video_path):
|
|
30 |
video_base64 = base64.b64encode(file.read()).decode()
|
31 |
return video_base64
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Upload videos
|
34 |
-
uploaded_files = st.file_uploader("Upload Video Files", type=["mp4"], accept_multiple_files=True)
|
35 |
|
36 |
if uploaded_files:
|
37 |
video_paths = []
|
@@ -40,25 +54,22 @@ if uploaded_files:
|
|
40 |
tfile.write(file.read())
|
41 |
video_paths.append(tfile.name)
|
42 |
|
43 |
-
st.write("Uploaded video files:", video_paths)
|
44 |
|
45 |
# Read videos and get frames
|
46 |
all_frames = []
|
47 |
for path in video_paths:
|
48 |
frames = read_video(path)
|
49 |
-
all_frames.
|
50 |
|
51 |
# Placeholder for future functionality
|
52 |
-
st.write("Interpolation will be performed here.")
|
|
|
|
|
|
|
53 |
|
54 |
-
# Compile frames into new video (placeholder)
|
55 |
-
st.write("The new video will be compiled here.")
|
56 |
-
|
57 |
-
# Assume output_video_path contains the path to the compiled video
|
58 |
-
output_video_path = "output_video.mp4"
|
59 |
-
|
60 |
# Provide download link for the video
|
61 |
-
video_base64 = get_video_base64(
|
62 |
st.markdown(f'### Download Output Video π₯')
|
63 |
-
href = f'<a href="data:video/mp4;base64,{video_base64}" download="
|
64 |
st.markdown(href, unsafe_allow_html=True)
|
|
|
30 |
video_base64 = base64.b64encode(file.read()).decode()
|
31 |
return video_base64
|
32 |
|
33 |
+
# Function to save frames to video
|
34 |
+
def save_frames_to_video(frames, output_video_path):
|
35 |
+
height, width, _ = frames[0].shape
|
36 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
37 |
+
out = cv2.VideoWriter(output_video_path, fourcc, 20.0, (width, height))
|
38 |
+
|
39 |
+
for frame in frames:
|
40 |
+
out.write(frame)
|
41 |
+
|
42 |
+
out.release()
|
43 |
+
|
44 |
+
# Textbox for user to specify output video name
|
45 |
+
output_video_name = st.text_input("Enter the name for the output video:", "Output_Video.mp4")
|
46 |
+
|
47 |
# Upload videos
|
48 |
+
uploaded_files = st.file_uploader("Upload Video Files π€", type=["mp4"], accept_multiple_files=True)
|
49 |
|
50 |
if uploaded_files:
|
51 |
video_paths = []
|
|
|
54 |
tfile.write(file.read())
|
55 |
video_paths.append(tfile.name)
|
56 |
|
57 |
+
st.write("Uploaded video files: π", video_paths)
|
58 |
|
59 |
# Read videos and get frames
|
60 |
all_frames = []
|
61 |
for path in video_paths:
|
62 |
frames = read_video(path)
|
63 |
+
all_frames.extend(frames)
|
64 |
|
65 |
# Placeholder for future functionality
|
66 |
+
st.write("Interpolation will be performed here. β³")
|
67 |
+
|
68 |
+
# Save frames to video
|
69 |
+
save_frames_to_video(all_frames, output_video_name)
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
# Provide download link for the video
|
72 |
+
video_base64 = get_video_base64(output_video_name)
|
73 |
st.markdown(f'### Download Output Video π₯')
|
74 |
+
href = f'<a href="data:video/mp4;base64,{video_base64}" download="{output_video_name}">Click here to download the video</a>'
|
75 |
st.markdown(href, unsafe_allow_html=True)
|