Skip to content

Instantly share code, notes, and snippets.

@miladfa7
Created November 29, 2023 10:43
Show Gist options
  • Save miladfa7/3ee799bb7a6d0de6c7fdf159e7c582d5 to your computer and use it in GitHub Desktop.
Save miladfa7/3ee799bb7a6d0de6c7fdf159e7c582d5 to your computer and use it in GitHub Desktop.
How to load and show video in Jupyter Notebook
import io
import base64
from IPython.display import HTML
video = io.open('21590891783.mp4', 'r+b').read()
encoded = base64.b64encode(video)
HTML(data='''
<video controls>
<source src="data:video/mp4;base64,{0}" type="video/mp4" />
</video>'''.format(encoded.decode('ascii')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment