We are currently running a Dash application on Databricks, where our files are also stored. As part of our dashboard, we embed MP4 videos using the standard Dash HTML components. While smaller video files work as expected, we have encountered issues when attempting to display larger MP4 files — specifically those approaching or exceeding ~500 MB. These videos fail to load or play reliably in the application.
Could you please clarify:
Are there any known limitations in Dash regarding MP4 video file size or playback?
Does Dash impose restrictions on serving large video files from the assets folder or other storage backends?
Would you recommend using streaming protocols (e.g., HLS, DASH) or external video hosting services for larger files instead of direct embedding?
Are there best practices for handling video playback in Dash when applications are deployed on Databricks?
Understanding these constraints will help us determine whether we should re-encode, compress, or restructure our video delivery pipeline to ensure smooth playback for end users.
Thank you in advance for your guidance. We appreciate your support in helping us optimize our Dash application.
Hey @gergo , you may consider trying Dash Player ( Dash Player | Dash for Python Documentation | Plotly ) with hosted content rather than the html.Video component. html.Video won’t stream the content, so it won’t work well for large files. Dash Player with hosted content will work with that streaming automatically.
Be aware that Dash Player won’t stream local files, so for a file in the range of 500mb, we recommend uploading to a supported video service and using Dash Player to manage that embed..
@gergo experimenting with this, and it looks like Dash Player can handle streaming. Here’s an example code snippet.
You can see the video and observe the streaming behaviour in https://video-player-example.plotly.app. You’ll just need to set up a Flask route in your Dash app for Dash Player to look for.
# /// script
# dependencies = [
# "dash[cloud]",
# "flask",
# "dash-player"
# ]
# ///
from dash import Dash, html
import dash_player
from flask import send_from_directory
import os
app = Dash(__name__)
# Route to serve video files with streaming support
@app.server.route('/videos/<path:filename>')
def serve_video(filename):
video_directory = os.path.join(os.getcwd(), 'videos')
return send_from_directory(
video_directory,
filename,
conditional=True # Enables HTTP range requests for streaming
)
# App layout
app.layout = html.Div([
html.H1("Video Player Example"),
dash_player.DashPlayer(
id='video-player',
url='/videos/example.mp4',
controls=True,
width='100%',
height='400px'
)
])
if __name__ == '__main__':
app.run(debug=True)