pn23 commited on
Commit
d82ccc8
·
verified ·
1 Parent(s): 5d6d140

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,6 +1,14 @@
1
  import streamlit as st
2
  import io
3
  import cv2
 
 
 
 
 
 
 
 
4
 
5
 
6
  st.title("Play Uploaded File")
@@ -39,8 +47,14 @@ if uploaded_file is not None:
39
  output.release()
40
  cap.release()
41
 
42
- with open('output.mp4', 'wb') as f:
43
- st.download_button('Download Video', f, file_name='output.mp4')
 
 
 
 
 
 
44
 
45
 
46
  # @st.cache(allow_output_mutation=True)
 
1
  import streamlit as st
2
  import io
3
  import cv2
4
+ import base64
5
+
6
+
7
+ def get_video_content_as_base64(video_file):
8
+ with open(video_file, "rb") as f:
9
+ video_bytes = f.read()
10
+ encoded_video = base64.b64encode(video_bytes).decode()
11
+ return encoded_video
12
 
13
 
14
  st.title("Play Uploaded File")
 
47
  output.release()
48
  cap.release()
49
 
50
+ # Get the base64 encoded content of the video file
51
+ video_base64 = get_video_content_as_base64('output.mp4')
52
+
53
+ # Create a download button
54
+ st.markdown(
55
+ f'<a href="data:video/mp4;base64,{video_base64}" download="your_video.mp4">Download video</a>',
56
+ unsafe_allow_html=True,
57
+ )
58
 
59
 
60
  # @st.cache(allow_output_mutation=True)