St.video not working for own video files (H264)

Is anyone else finding st.video NOT WORKING for their own mp4 video files, but IS WORKING for youtube urls.

I have tried my best to figure this one out, but hitting a wall now after lots of tries.

Iā€™m using code just as in the API (below), and made sure my test video sample is H.264 encoded, and is routed to the folder where the file is, so I think Iā€™ve avoided all simple mistakes. Interestingly, the Streamlit API webpage video is no longer showing the lovely starry night sky video it did a few months back (both on my laptop and my phone) which has prompted me to think it could be Streamlit rather than me?!

video_file = open(ā€˜myvideo.mp4ā€™, ā€˜rbā€™)
video_bytes = video_file.read()

st.video(video_bytes)

Is it me, or maybe there is system bug?!

Any suggestions very welcome as I want to avoid using Youtube as a middle man.
Thanks!

Please see the st.video docstring, which explains the issue with H264 encoding

https://docs.streamlit.io/en/stable/api.html?highlight=Video#streamlit.video

Thanks. Yes I had tried to follow that note, and made sure I had H264 encoding, but still not working which is why I was reaching out for help.

Which one do you have? mp4 or H.264? Where did the video come from?

Thanks for help.
I tested with h.264 which came from https://textinmotion.com/help/samples

Thanks for clarifying @ajhayes83, I didnā€™t realize that a video can both be mp4 (which is a container) AND H.264. Iā€™ll consider how the docs could be changed. edit: on careful reading, I see that the docs are correct in that they mention the encoding not being mp4v, not that a video canā€™t both be mp4 and h.264. Will be more careful in future responsesā€¦

However, this is working for me on Ubuntu 18.04 and Chrome:

import streamlit as st

with open("/home/rzwitch/Downloads/TextInMotion-VideoSample-576p.mp4", 'rb') as v:
    st.video(v)

What OS/browser are you using?

Hi, thanks.
I switched from Safari v13.1 to Firefox browser 78.0.1 and it works on Firefox! So its a browser problem! Nothing to do with Streamlit. I might need to add a ā€˜troubleshootingā€™ sidebar radiobutton to the Streamlit App Iā€™m working on to alert users that Safari browser may struggle with videoā€¦Iā€™ll have a think.

I donā€™t know if you think it could be worth adding a note to your Streamlit API at the st.video docstring about this (Safari) browser problem to avoid others falling into same trap as meā€¦
Thanks for your patience.
Alastair

1 Like