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>

I also had the same problem with JupyterLab. The IPython.display and %%HTML solutions did not work for me.
Then, I tried the MoviePy library instead. It solved the problem.
Here is the code that worked for me:
from moviepy.editor import *
path="you_video_file_path"
clip=VideoFileClip(path)
clip.ipython_display(width=500)
from moviepy import VideoFileClip
path="you_video_file_path"
clip=VideoFileClip(path)
clip.display_in_notebook(width=500)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With