Kevin King commited on
Commit
dbc0e16
·
1 Parent(s): 7a9e214

FEAT: Add minimal video upload and playback

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +19 -9
src/streamlit_app.py CHANGED
@@ -1,12 +1,22 @@
1
  import streamlit as st
2
- from moviepy.editor import VideoFileClip
 
3
 
4
- st.set_page_config(page_title="MoviePy Test")
5
- st.title("Testing `moviepy` Installation")
6
 
7
- try:
8
- # This line will only succeed if moviepy is installed correctly
9
- st.success("Successfully imported `VideoFileClip` from `moviepy.editor`!")
10
- st.write("This confirms that the `moviepy` library was installed correctly.")
11
- except ImportError as e:
12
- st.error(f"Failed to import `moviepy`. Error: {e}")
 
 
 
 
 
 
 
 
 
 
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)