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 :: how to make python open a program/desktop app 
Python :: audioplayer python 
Python :: randomly shuffle pandas dataframe 
Python :: merge dicts python 
Python :: getters and setters in python 
Python :: pow python 
Python :: how to remove none in python 
Python :: openpyxl check if worksheet exists 
Python :: NumPy unique Example Get the unique rows and columns 
Python :: how to install tkinter in pycharm 
Python :: python filter timestamp 
Python :: python array index range 
Python :: median of array python 
Python :: python not equal multiple values 
Python :: how to create python file in powershell 
Python :: python while true loop 
Python :: python for/else 
Python :: geopandas legend location 
Python :: print in python without using print 
Python :: filter dict 
Python :: python virtual enviroment 
Python :: how to get the link of an image in selenium python 
Python :: how to make gtts text to speech converter 
Python :: loop through words in a string python 
Python :: smtplib send caleneder email 
Python :: how to convert text to speech using pthon 
Python :: drop-trailing-zeros-from-decimal python 
Python :: how to make my discord bot shut down with a command 
Python :: map example in python 
Python :: plt get colors in range 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =