Cannot play local mp4 videos with html.Video

Hello, happy new year, and please excuse me for this basic question.

I have a very simple app here, in which I want to simply load a .mp4 video that’s stored locally on my computer, and play it. For some reason, all I get is a video player that hasn’t loaded the video and the play button is disabled. I would appreciate any help. I’m on a mac, so could it be due to file permissions or anything like that? I also tried on Ubuntu, same behavior.

I’ve tried different filepaths, and a different mp4 file.

My code is as follows:

import dash
from dash import html

app = dash.Dash(__name__)

app.layout = html.Div(children = [
        html.Video(
            controls = True,
            id = 'movie_player',
            src = "/Users/giannisdimaridis/Desktop/movie.mp4",
            autoPlay=True
        ),
    ])

if __name__ == '__main__':
    app.run_server(debug=True)

Hello @gdims and Happy New Year,

It is recommended to have all the static files (images, videos, etc) inside an assets folder on the same path where your app.py file resides. Adding Static Assets | Dash for Python Documentation | Plotly

Just paste your video file inside the assets folder and change the path to src = "assets/movie.mp4"

2 Likes

Thank you so much! It works fine.

1 Like