Spaces:
Sleeping
Sleeping
Kevin King
commited on
Commit
·
dbc0e16
1
Parent(s):
7a9e214
FEAT: Add minimal video upload and playback
Browse files- src/streamlit_app.py +19 -9
src/streamlit_app.py
CHANGED
|
@@ -1,12 +1,22 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
|
|
|
| 3 |
|
| 4 |
-
st.set_page_config(page_title="
|
| 5 |
-
st.title("
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import tempfile
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
st.set_page_config(page_title="Video Upload Test")
|
| 6 |
+
st.title("Video Upload and Playback Test")
|
| 7 |
|
| 8 |
+
# Create a file uploader widget
|
| 9 |
+
uploaded_file = st.file_uploader("Choose a video file...", type=["mp4", "mov", "avi", "mkv"])
|
| 10 |
+
|
| 11 |
+
if uploaded_file is not None:
|
| 12 |
+
# The uploader gives us an in-memory file buffer.
|
| 13 |
+
# We need to save it to a temporary file on the server's disk for st.video to use it.
|
| 14 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tfile:
|
| 15 |
+
tfile.write(uploaded_file.read())
|
| 16 |
+
temp_video_path = tfile.name
|
| 17 |
+
|
| 18 |
+
# Display the video player
|
| 19 |
+
st.video(temp_video_path)
|
| 20 |
+
|
| 21 |
+
# Clean up the temporary file after use
|
| 22 |
+
os.unlink(temp_video_path)
|