Introduction
This project shows you how to build a video player web app using Python and Streamlit. Users can upload any video file directly in the browser and watch it with built-in playback controls — no extra software required.
> 🎬 Watch the Full Video Tutorial:
> Watch the walkthrough on YouTube: TOP Python PRO Shares Video Player SECRETS Using Streamlit
Prerequisites
code
pip install streamlitStep 1: Create the Script
Create video_player.py and paste the following:
code
import streamlit as st
st.set_page_config(page_title="Video Player", page_icon="🎬")
st.title("🎬 Video Player")
st.write("Upload a video file to play it directly in your browser.")
uploaded_file = st.file_uploader(
"Choose a video file",
type=["mp4", "mov", "avi", "mkv", "webm"]
)
if uploaded_file is not None:
file_details = {
"File Name": uploaded_file.name,
"File Size": f"{uploaded_file.size / (1024 * 1024):.2f} MB",
"File Type": uploaded_file.type,
}
st.subheader("📋 File Information")
for key, value in file_details.items():
st.write(f"**{key}:** {value}")
st.subheader("▶️ Now Playing")
st.video(uploaded_file)
st.success("Video loaded! Use the player controls to play, pause, or seek.")
else:
st.info("Please upload a video file to get started.")Step 2: Run the App
code
streamlit run video_player.pyStep 3: Use the Video Player
Open the app in your browser, click Browse files, and select a video. The file info panel and video player appear instantly below.
Key Concepts
video/mp4.Supported Formats
| Format | Extension | Notes |
|---|---|---|
| MP4 | .mp4 | Most common, best browser support |
| WebM | .webm | Open format, great for the web |
| MOV | .mov | Apple QuickTime format |
| AVI | .avi | Windows Media format |
| MKV | .mkv | Matroska container |