Open parmentelat opened 1 year ago
Heya, have you seen https://github.com/sphinx-contrib/video
In my use case, I teach using live interactive notebooks with embedded <video>
elements, so regular Jupyter/RISE needs to understand it. Then I use Jupyter Book to publish the rendered content as a reference for students (with Thebe and Binder in case they want to interact, or they clone the repo locally). html_image
has been essential to be able to render/position within Jupyter/RISE while getting correct output on the class website. But <video>
path handling is currently broken and I've been hacking my _build
outputs with sed
to repair the paths. I would love to see html_video
even if only to avoid this manual path hacking.
FWIW the way I do it on my end is to
_static
from ipywidgets import Video
Video.from_file("_static/thevideo.mp4", autoplay=False)
this turns out to render in both jlab and jupyter book, without the need for messing with paths (except of course for the constraint to store the video in _static
which I agree is a moderate pain)
@chrisjsewell the reference to sphinx-contrib/video is interesting but IIUC the example relies on ReST rather than MyST
.. video:: _static/video.mp4
are you suggesting that we can use
```{video} _static/thevideo.mp4
instead ? and if yes, would that work even if the video is not under `_static`, like we can do with `{image}` ?
are you suggesting that we can use
yep exactly; there should be no reason it does not work exactly like for RST (the same as for every other directive)
I haven't had a chance to try out though, maybe you can report back
so it feels like I must be doing something very wrong, because:
I create a notebook and add this in a cell
this one is under `_static/`
```{video} _static/under-static.mp4
this one is under media/
so first in JupyterLab with jupyterlab-myst
it renders like this
then in the output of jupyter book I see this
correction: once I add
sphinxcontrib.video
to sphinx's extra_extensions, I am getting this in the jupyter book output:
the video under _static
gets properly packaged in the html output but not the one under another folder, specifically here ./media/
is there something else I need to do to improve these results ?
to be exhaustive, here's the versions that I have installed
pip list | grep -Ei 'myst|sphinx'
jupyterlab_myst 2.1.0
myst-nb 0.17.2
myst-parser 0.18.1
pydata-sphinx-theme 0.14.4
Sphinx 5.0.2
sphinx-book-theme 1.0.1
sphinx-comments 0.0.3
sphinx-copybutton 0.5.2
sphinx_design 0.3.0
sphinx-exercise 0.4.1
sphinx_external_toc 0.3.1
sphinx-jupyterbook-latex 0.5.2
sphinx-multitoc-numbering 0.1.3
sphinx-rtd-theme 2.0.0
sphinx-thebe 0.2.1
sphinx-togglebutton 0.3.2
sphinxcontrib-applehelp 1.0.7
sphinxcontrib-bibtex 2.5.0
sphinxcontrib-devhelp 1.0.5
sphinxcontrib-htmlhelp 2.0.4
sphinxcontrib-jquery 4.1
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-mermaid 0.9.2
sphinxcontrib-qthelp 1.0.6
sphinxcontrib-serializinghtml 1.1.9
sphinxcontrib-video 0.2.0
finally I just noticed that with the one combo that does work (within jupyter book output, referring to a video stored under _static
) I can't seem to change the size of the rendered
Context
this is a follow-up to https://github.com/executablebooks/jupyter-book/issues/1249
Proposal
in essence, the proposal is to create a new
html_video
extension that would behave much likehtml_image
and would let users insert rawvideo
html tags the main effect being - as far as I am concerned - for the referred media file to be copied over in the jb build areaTasks and updates
in particular the
<video>
tag differs a bit from<img>
in that it allows for asrc
attribute, but also to insert<source>
-tagged children in a way that makes it a little more complex to deal with