Skip to content

Instantly share code, notes, and snippets.

@thanasi
Last active February 15, 2022 08:48
Show Gist options
  • Save thanasi/ad31f798b747629e717bcebd2cad15cf to your computer and use it in GitHub Desktop.
Save thanasi/ad31f798b747629e717bcebd2cad15cf to your computer and use it in GitHub Desktop.
Embed a local video file in a Jupyter Notebook
#########################################
# using cell magic
#########################################
%%HTML
<div align="middle">
<video width="80%" controls>
<source src="path/to/my.mp4" type="video/mp4">
</video></div>
#########################################
# explicitly calling the HTML renderer:
#########################################
from IPython.display import HTML
HTML("""
<div align="middle">
<video width="80%" controls>
<source src="path/to/my.mp4" type="video/mp4">
</video></div>""")
@avinashpaul
Copy link

same here I have a black video preview and that's it. Any insights regarding this?

@thanasi
Copy link
Author

thanasi commented Feb 15, 2022

This snippet is a bit outdated now. The IPython.display module now contains classes for embedding local and remote video content.

https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment