st.video() in Streamlit
In Streamlit, st.video() embeds a video player directly in your app. It supports local video files, URLs (including YouTube), and raw bytes, making it useful for tutorials, dashboards, ML demos, and media apps.
Basic Syntax
st.video(data, format="video/mp4", start_time=0)
The function has the following parameters:
- data: File path, URL, bytes, or file-like object
- format: Video format (mp4, webm, ogg)
- start_time: Start playback from a specific second
Example: Play a local video file.
Python
import streamlit as st
st.title("Local Video Example")
st.video("sample_video.mp4") - Embeds a video player inside the app.
- Supports local files and online video URLs.
- Starts playback automatically when the player loads.
✔ Useful for tutorials, demos, and offline apps.