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