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 :: python efficiently find duplicates in list 
Python :: Access the Response Methods and Attributes in python Get the HTML of the page 
Python :: the boys 
Python :: render django 
Python :: outliers removal 
Python :: colab version python 
Python :: convert text to speech in python 
Python :: flask heroku 
Python :: logging - multiple log file 
Python :: loop through list of dictionaries python 
Python :: label encoding in python 
Python :: requests.packages.urllib3.util.retry could not be resolved from source 
Python :: seaborn correlation heatmap 
Python :: print typeof in python 
Python :: django filter by date range 
Python :: web scraping python beautifulsoup 
Python :: strip first occurence of substring python 
Python :: how to convert binary to text in python 
Python :: find all color in image python 
Python :: sending whatsapp message using python 
Python :: best python ide for ubuntu 
Python :: add x=y line to scatter plot python 
Python :: opencv python grayscale image to color 
Python :: Image Watermarking in python 
Python :: count characters in string python 
Python :: remove ,drop,effacer, dataframe,python 
Python :: maxsize in python 
Python :: distance between numpy arrays 
Python :: pyqt disable maximize button 
Python :: find factorial in python 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =