Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Play Video in Google Colab

from IPython.display import HTML
from base64 import b64encode
 
def show_video(video_path, video_width = 600):
   
  video_file = open(video_path, "r+b").read()
 
  video_url = f"data:video/mp4;base64,{b64encode(video_file).decode()}"
  return HTML(f"""<video width={video_width} controls><source src="{video_url}"></video>""")
 
show_video(video_path)
Comment

how to play video in colab

## for short videos
from IPython.display import HTML
from base64 import b64encode
mp4 = open('video.mp4','rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML("""
<video width=400 controls>
      <source src="%s" type="video/mp4">
</video>
""" % data_url)
========================================================
## for large videos
!pip install -U kora
from kora.drive import upload_public
url = upload_public('video.mp4')
# then display it
from IPython.display import HTML
HTML(f"""<video src={url} width=500 controls/>""")
Comment

play video in colab

from IPython.display import HTML
from base64 import b64encode
mp4 = open('video.mp4','rb').read()
data_url = "data:video/mp4;base64," + b64encode(mp4).decode()
HTML("""
<video width=400 controls>
      <source src="%s" type="video/mp4">
</video>
""" % data_url)
Comment

add video in google colab

!pip install pytube==9.1.0
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=-ncJV0tMAjE&t=72s')
Comment

PREVIOUS NEXT
Code Example
Python :: time it python 
Python :: python list files in current directory 
Python :: python check is os is windows 
Python :: pip clear cache command 
Python :: python get utc time 
Python :: requests get image from url 
Python :: How to have add break for a few seconds in python 
Python :: python read json 
Python :: pandas groupby agg count unique 
Python :: get stats from array 
Python :: how to automatically copy an output to clipboard in python 
Python :: how to make a python program to convert inch into cm 
Python :: python iterate directory 
Python :: meter to cm in python 
Python :: incognito mode in selenium 
Python :: dictionary from two lists 
Python :: python date add days 
Python :: python gettext 
Python :: what skills do you need to master pvp in minecraft 
Python :: pandas dropna specific column 
Python :: python reload file if changed 
Python :: export file csv 
Python :: python randomly shuffle rows of pandas dataframe 
Python :: pandas tuple from two columns 
Python :: pandas remove char from column 
Python :: python delete none from list 
Python :: python find dict in list of dict by id 
Python :: python savefig full screen 
Python :: python play sound 
Python :: how to change window size in kivy python 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =