I am trying to upload a video file and render it frame by frame using OpenCV’s
VideoCapture object. The problem is that the frames are rendered properly on my local system as you can see here:
However, while deploying it on streamlit Cloud, the frames are not rendered properly as you can see here:
as you can notice in the Manage app tab, it shows:
MediaFileHandler: Missing file d021d4eba9e69343fdeefd510cd55fc4076876433ca1666098101905.jpg.
My code is simple:
st.title('Video Upload and display') up_file = st.file_uploader("Upload a Video", ['mp4','mov', 'avi']) stframe = st.empty() if up_file: tfile = tempfile.NamedTemporaryFile(delete=False) tfile.write(up_file.read()) vf = cv2.VideoCapture(tfile.name) while vf.isOpened(): ret, frame = vf.read() if not ret: break # convert frame from BGR to RGB. frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) stframe.image(frame) vf.release() stframe.empty() tfile.close()
Can someone please point out if am I missing something here?