jupyter-book
jupyter-book copied to clipboard
Support for video
Context
First of all, I'd like to thank you for the amazing work! jupyter-book is super easy to use and produces really good results 🙂
I would like to include some videos in my book, and I've found a Sphinx extension called sphinxcontrib-video. To use it, I have
pip install sphinxcontrib-video- Added
sphinxcontrib.videotosphinx: extra_extensions - Added a Markdown code like
```{video} ../videos/movie.mp4
:width: 320
:height: 240
``` _
This almost worked, since the book compiled and a placeholder for the video is shown in the html page. The problem is that the video does not start. By looking into the build folder I can see that the mp4 has been correctly copied. However, by inspecting the html file I can see that the source is still set to ../videos/movie.mp4.
If I fix the path in the html file then everything works fine, but it's a little cumbersome.
Is that something that you could fix, or it should be addressed by sphinxcontrib-video?
Thanks a lot 🙂
Proposal
- Correct relative path for video.
- Write about support for videos in the documentation.
Tasks and updates
No response
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
I've found a workaround which does not require sphinxcontrib-video and works fine.
First, tell sphinx to copy the assets from the videos folder into the _build one.
sphinx:
config:
html_extra_path: ['./videos']
Then, write a standard HTML tag in the Markdown file.
<video controls autoplay muted="true" loop="true" width="500">
<source src="./movie.mp4" type="video/mp4">
</video>
I was expecting a slightly different path, as explained in the documentation, but on my machine the video was copied into _build\html.
thanks for bringing this up @RRiva.
Is that something that you could fix, or it should be addressed by sphinxcontrib-video?
I suspect that the path is set by sphinxcontrib-video but I will try and find some time to confirm this. It would be nice to use sphinxcontrib-video.
Thanks @mmcky for looking into this! Some time ago I stumbled upon a nice blog post that explains a third method to include videos: Adding videos in JupyterBook. This solution is better than the one above, since it allows to use different folders, and therefore avoids names conflicts.
I think that we have two alternatives:
- Support
sphinxcontrib-video. This will allow to embed videos using Markdown syntax, but requires an extension that isn't maintained anymore. - Bring the blog post into the documentation. This works out of the box, but requires mixing HTML and Markdown.
Personally, I'm in favor of option 2.