celluloid icon indicating copy to clipboard operation
celluloid copied to clipboard

View videos in colab

Open chsher opened this issue 2 years ago • 3 comments

Is there a way to view videos in google colab?

chsher avatar Aug 29 '21 20:08 chsher

Same question!

lakesare avatar Feb 04 '22 05:02 lakesare

from IPython.display import HTML, display
import base64

def Video(path, width=800, type='mp4'):
  display(HTML(f"<video width={width} controls src='data:video/{type};base64,{(base64.b64encode(open(path, 'rb').read()).decode('utf-8'))}'>" ))

Video('vid.mp4')

works fine on videos with relatively small sizes.

ref: https://stackoverflow.com/a/68294183, https://stackoverflow.com/a/57378660

Goblin80 avatar Feb 04 '22 16:02 Goblin80

Oh, that's a great idea. Thank you!

lakesare avatar Feb 04 '22 21:02 lakesare