Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import streamlit as st
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import tempfile
|
|
|
6 |
|
7 |
# Streamlit app title
|
8 |
st.title("Video Interpolation App 🎥")
|
@@ -23,6 +24,12 @@ def read_video(video_path):
|
|
23 |
def interpolate_frames(frame1, frame2, alpha):
|
24 |
return cv2.addWeighted(frame1, 1 - alpha, frame2, alpha, 0)
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
# Upload videos
|
27 |
uploaded_files = st.file_uploader("Upload Video Files", type=["mp4"], accept_multiple_files=True)
|
28 |
|
@@ -46,3 +53,12 @@ if uploaded_files:
|
|
46 |
|
47 |
# Compile frames into new video (placeholder)
|
48 |
st.write("The new video will be compiled here.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
import tempfile
|
6 |
+
import base64
|
7 |
|
8 |
# Streamlit app title
|
9 |
st.title("Video Interpolation App 🎥")
|
|
|
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:
|
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 |
|
|
|
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 = "path/to/output_video.mp4"
|
59 |
+
|
60 |
+
# Provide download link for the video
|
61 |
+
video_base64 = get_video_base64(output_video_path)
|
62 |
+
st.markdown(f'### Download Output Video 📥')
|
63 |
+
href = f'<a href="data:video/mp4;base64,{video_base64}" download="output_video.mp4">Click here to download the video</a>'
|
64 |
+
st.markdown(href, unsafe_allow_html=True)
|