I am hoping to allow a user to upload a mp4 or mkv clip with streamlit’s file_uploader function, and then use the uploaded video in an imageio.get_reader function. So far I have tried various options:
inp_vid = st.sidebar.file_uploader("Upload driving video", type=(["mp4", "mkv"]))
if inp_vid:
reader = imageio.get_reader(inp_vid)
which results in a Could not find a format to read the specified file in any-mode mode'
value error and a " Could not find a format to read the specified file in %s mode % modename"
error in the get_reader funciton.
I have also tried:
inp_vid = st.sidebar.file_uploader("Upload driving video", type=(["mp4", "mkv"]))
if inp_vid:
with tempfile.NamedTemporaryFile() as fp:
fp.write_bytes(inp_vid.read())
reader = imageio.get_reader(fp.name)
which gives a '_io.BufferedRandom' object has no attribute 'write_bytes' attribute error.
I’ve also tried
inp_vid = st.sidebar.file_uploader("Upload driving video", type=(["mp4", "mkv"]))
if inp_vid:
tfile = tempfile.NamedTemporaryFile(delete=False)
tfile.write(inp_vid.read())
which gives the same error as the first code I mentioned.
I’m evidently not really familiar with all the bytes IO stuff, so any help would be greatly appreciated!