如何在我的 IPython notebook 中播放本地视频? [英] How can I play a local video in my IPython notebook?
问题描述
我有一个本地视频文件(.avi,但可以转换),我想向客户展示(即它是私人的,不能发布到网络),但我不能弄清楚如何在 IPython notebook 中播放它.
I've got a local video file (an .avi, but could be converted) that I would like to show a client (ie it is private and can't be published to the web), but I can't figure out how to play it in IPython notebook.
经过一点谷歌搜索后,似乎 HTML5 视频标签是可行的方法,但我不知道任何 html 并且无法播放.
After a little Googling it seems that maybe the HTML5 video tag is the way to go, but I don't know any html and can't get it to play.
对如何嵌入这个有任何想法吗?
Any thoughts on how I can embed this?
推荐答案
(2019年更新,移除了不必要的昂贵方法)
就去做:
from IPython.display import Video
Video("test.mp4")
如果您收到错误没有找到支持格式或 MIME 类型的视频
,只需将 embed=True
传递给函数:Video("test.mp4", embed=True)
.
If you get an error No video with supported format or MIME type found
, just pass embed=True
to the function: Video("test.mp4", embed=True)
.
或者如果你想使用 HTML
元素:
Or if you want to use the HTML
element:
from IPython.display import HTML
HTML("""
<video alt="test" controls>
<source src="test.mp4" type="video/mp4">
</video>
""")
这篇关于如何在我的 IPython notebook 中播放本地视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!