pn23 commited on
Commit
2b67bc1
·
verified ·
1 Parent(s): d7e19e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -8
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
- g = io.BytesIO(uploaded_file.read()) ## BytesIO Object
13
- temporary_location = "testout_simple.mp4"
14
-
15
- with open(temporary_location, 'wb') as out: ## Open temporary file as bytes
16
- out.write(g.read()) ## Read bytes into file
17
-
18
- # close file
19
- out.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)