cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to Play or Stream MP4 Videos from Unity Catalog Volumes in Databricks (Flask/Dash)?

GergoBo
Visitor

Hello Databricks Community,

I am working on a Dash dashboard (Python/Flask backend) deployed on Databricks, and I need to play or stream MP4 video files stored in a Unity Catalog Volume. I have tried accessing these files both from a Databricks notebook and from Flask, but I am unable to play the videos in either environment.

  • In notebooks, I can read the files, but I cannot play or display the videos directly in the output cells.
  • In Flask/Dash, I cannot serve the files as public URLs, and the backend cannot access the volume as a file path for streaming.

Has anyone found a way to play or stream MP4 videos stored in Unity Catalog Volumes, either in a Databricks notebook or via a web app (Flask/Dash) running on Databricks?
Are there any recommended approaches, workarounds, or best practices for enabling video playback from Volumes?

Any advice or documentation links would be greatly appreciated!

Thank you!

1 REPLY 1

Raman_Unifeye
Contributor III

@GergoBo - Since notebooks cannot reach out to the file system to stream, you must embed the video as a Base64 encoded string. 

I tried below code and it works well in Notebook as it plays the video in the output.

 

import base64
from IPython.display import HTML

video_path = "/Volumes/workspace/ingestion/vol1/mp4/file_example_MP4_480_1_5MG.mp4"

with open(video_path, "rb") as f:
data = f.read()
b64_video = base64.b64encode(data).decode()

HTML(f"""
<video width="640" height="480" controls>
<source src="data:video/mp4;base64,{b64_video}" type="video/mp4">
</video>
""")

This works best for small files (<50MB) as it loads the whole video into memory.

Pls try above. I will check for Dash-app as it is more involved and try to get back.


RG #Driving Business Outcomes with Data Intelligence