0

I'm doing this

from IPython.display import Video
Video(sample_video_url)

sample_video_url is a string and contain a video url. It works only with this kind of url: https://cvbp.blob.core.windows.net/public/datasets/action_recognition/action_sample.mp4

I have to work with many videos, so I tried to put you_tube urls, or video urls from my computer but it doesn't work.

After Video(sample_video_url) I have other lines code, but before I want to understand the problem. Thanks

Alex I
  • 19,689
  • 9
  • 86
  • 158

1 Answers1

0

I found this question (source) which seems like it is very closely related to your problem. I think you may be missing some essential formatting here.

Note: I uploaded the videos to the file browser/list of notebooks before this worked completely on my system

See:

from IPython.display import Video

Video("test.mp4")

That particular question that I linked also shows how you can use HTML5 formatting to include video as well:

from IPython.display import HTML

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

For Youtube videos this works:

from IPython.display import YouTubeVideo
youtube_video = YouTubeVideo('video-url-string-here')
display(youtube_video)

There's also the magic cell method:

%%HTML
<video width="320" height="240" controls>
  <source src="path/to/your.mp4" type="video/mp4">
</video>
octo-star
  • 1
  • 3