Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal for a html_video extension #651

Open
3 tasks
parmentelat opened this issue Dec 11, 2022 · 9 comments
Open
3 tasks

proposal for a html_video extension #651

parmentelat opened this issue Dec 11, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@parmentelat
Copy link

Context

this is a follow-up to
jupyter-book/jupyter-book#1249

Proposal

in essence, the proposal is to create a new html_video extension that would behave much like html_image and would let users insert raw video 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 area

Tasks and updates

  • agree on the relevance
  • fine-tune the definition of the expected behaviour;
    in particular the <video> tag differs a bit from <img> in that it allows for a src attribute, but also to insert <source>-tagged children in a way that makes it a little more complex to deal with
  • update documentation and examples
@chrisjsewell
Copy link
Member

Heya, have you seen https://github.com/sphinx-contrib/video

@jedbrown
Copy link

jedbrown commented Dec 7, 2023

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.

@parmentelat
Copy link
Author

FWIW
the way I do it on my end is to

  • store the video content in _static
  • insert it in the notebook in a code cell that reads
    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)

@parmentelat
Copy link
Author

@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} ?

@chrisjsewell
Copy link
Member

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

@parmentelat
Copy link
Author

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/`

```{video} media/under-media.mp4

so first in JupyterLab with jupyterlab-myst it renders like this

image

then in the output of jupyter book I see this

image

@parmentelat
Copy link
Author

parmentelat commented Dec 19, 2023

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 ?

image

@parmentelat
Copy link
Author

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

@parmentelat
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants