Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,14 +9,29 @@ uploaded_file = st.file_uploader("Choose a video...", type=["mp4"])
|
|
| 9 |
temporary_location = False
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
# @st.cache(allow_output_mutation=True)
|
|
|
|
| 9 |
temporary_location = False
|
| 10 |
|
| 11 |
if uploaded_file is not None:
|
| 12 |
+
video_file = st.file_uploader(‘video’, type = [‘mp4’])
|
| 13 |
+
cap = cv2.VideoCapture(video_file)
|
| 14 |
+
|
| 15 |
+
output = cv2.VideoWriter(“path”,cv2.VideoWriter_fourcc(*’MPEG’),30,(1080,1920))
|
| 16 |
+
|
| 17 |
+
while cap.isOpened():
|
| 18 |
+
# Capture frame-by-frame
|
| 19 |
+
ret, frame = cap.read()
|
| 20 |
+
# if frame is read correctly ret is True
|
| 21 |
+
if not ret:
|
| 22 |
+
print("Can't receive frame (stream end?). Exiting ...")
|
| 23 |
+
break
|
| 24 |
+
# Our operations on the frame come here
|
| 25 |
+
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
|
| 26 |
+
output.write(frame)
|
| 27 |
+
# Display the resulting frame
|
| 28 |
+
cv.imshow('frame', gray)
|
| 29 |
+
if cv.waitKey(1) == ord('q'):
|
| 30 |
+
break
|
| 31 |
+
|
| 32 |
+
cv2.destroyAllWindows()
|
| 33 |
+
output.release()
|
| 34 |
+
cap.release()
|
| 35 |
|
| 36 |
|
| 37 |
# @st.cache(allow_output_mutation=True)
|