This is my code:
if path_type=="mp4":
temp_file_result = './temp_file_2.mp4'
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(uploaded_file.read())
cap = cv2.VideoCapture(tfile.name)
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
new_my_video = './temp_file_2.mp4'
out = cv2.VideoWriter(new_my_video, fourcc, 18, (frame_width, frame_height))
while(cap.isOpened()):
ret, frame = cap.read()
if ret==True:
age_img = classify_age(frame)
age_img = cv2.cvtColor(age_img, cv2.COLOR_BGR2RGB)
out.write(age_img)
else:
break
st.video(new_my_video)
cap.release()
out.release()
However, I only get an empty video player.