Display Video on JupyterLab Notebook on GCP

Viewed 1255

I am having trouble display/embedding a video in a Notebook in Jupyter Lab. I have tried multiple ways to display a video, but it just does not play the video. The player loads but does not load the video. I am using JupyterLab on a Google Cloud (GCP) VM.

Attempt 1:

from IPython.display import Video

Video(LOCAL_PATH)

Attempt 2:

from IPython.display import HTML

HTML("""
    <video alt="test" controls>
        <source src="./video.mov" type="video/mov">
    </video>
""")

Attempt 3:

%%html
    <video width='480' height='480' controls>
        <source src='./video.mov'>
    </video>

enter image description here

2 Answers

I created a code cell and use the following code and works for youtube, a MP4 video and .mov video. My videos are ~2 MBs each. Are you loading a large video?

%%HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/3SeRMd0tGms?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
from IPython.display import Video
Video("video.mp4")
from IPython.display import Video
Video("movie.mov")

enter image description here

I also has the same problem with JupyterLab. The IPython.display and %%HTML solution do not work for me. Then, I used moviepy library instead. It solved the problem.

from moviepy.editor import *

path="you_video_file_path" 

clip=VideoFileClip(path)
clip.ipython_display(width=500)
Related