Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,6 @@
|
|
| 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")
|
|
@@ -38,17 +30,27 @@ if uploaded_file is not None:
|
|
| 38 |
break
|
| 39 |
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
cv2.destroyAllWindows()
|
| 44 |
output.release()
|
| 45 |
cap.release()
|
| 46 |
|
| 47 |
-
|
| 48 |
-
video_base64 = get_video_content_as_base64('output.mp4')
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import io
|
| 3 |
import cv2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
st.title("Play Uploaded File")
|
|
|
|
| 30 |
break
|
| 31 |
|
| 32 |
|
|
|
|
| 33 |
|
| 34 |
cv2.destroyAllWindows()
|
| 35 |
output.release()
|
| 36 |
cap.release()
|
| 37 |
|
| 38 |
+
display_video_frames()
|
|
|
|
| 39 |
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def capture_video_frames():
|
| 43 |
+
cap = cv2.VideoCapture('output.mp4')
|
| 44 |
+
while True:
|
| 45 |
+
ret, frame = cap.read()
|
| 46 |
+
yield frame
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def display_video_frames():
|
| 50 |
+
st.title("Live Video Stream")
|
| 51 |
+
frame_generator = capture_video_frames()
|
| 52 |
+
for frame in frame_generator:
|
| 53 |
+
# Convert the frame from OpenCV's BGR format to RGB format
|
| 54 |
+
frame_rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
| 55 |
+
# Display the frame using Streamlit
|
| 56 |
+
st.image(frame_rgb, channels="RGB", use_column_width=True)
|