Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,6 @@ def read_video(video_path):
|
|
20 |
cap.release()
|
21 |
return frames
|
22 |
|
23 |
-
# Function to interpolate between two frames
|
24 |
-
def interpolate_frames(frame1, frame2, alpha):
|
25 |
-
return cv2.addWeighted(frame1, 1 - alpha, frame2, alpha, 0)
|
26 |
-
|
27 |
# Function to convert video file to base64
|
28 |
def get_video_base64(video_path):
|
29 |
with open(video_path, "rb") as file:
|
@@ -32,13 +28,15 @@ def get_video_base64(video_path):
|
|
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,
|
38 |
|
39 |
for frame in frames:
|
40 |
out.write(frame)
|
41 |
-
|
42 |
out.release()
|
43 |
|
44 |
# Textbox for user to specify output video name
|
|
|
20 |
cap.release()
|
21 |
return frames
|
22 |
|
|
|
|
|
|
|
|
|
23 |
# Function to convert video file to base64
|
24 |
def get_video_base64(video_path):
|
25 |
with open(video_path, "rb") as file:
|
|
|
28 |
|
29 |
# Function to save frames to video
|
30 |
def save_frames_to_video(frames, output_video_path):
|
31 |
+
if not frames:
|
32 |
+
return
|
33 |
+
|
34 |
height, width, _ = frames[0].shape
|
35 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
36 |
+
out = cv2.VideoWriter(output_video_path, fourcc, 30.0, (width, height))
|
37 |
|
38 |
for frame in frames:
|
39 |
out.write(frame)
|
|
|
40 |
out.release()
|
41 |
|
42 |
# Textbox for user to specify output video name
|