Add support for video files in Sphinx
Closed, ResolvedPublic

Description

Summary
Create an extension to embed videos in a page created with Sphinx.

Required skills:
Python, knowledge about Sphinx might be helpful.

Description
There seems to be no extension to add videos to the generated pages.
At the moment one needs to do something like

.. raw:: html

   <video src="https://cdn.kde.org/hig/video/20180620-1/CardLayout1.webm" loop="true" playsinline="true" width="536" controls="true" onended="this.play()" class="border"></video>

to add a video.
I would envision a syntax like for images

.. image:: /img/Card5.qml.png
   :alt: Cards with 16x9, 4x3, 1x1 header image aspect ratio

for videos

.. video:: /img/CardLayout1.webm
   :alt: Resizing a card layout

See https://github.com/sphinx-contrib for an introduction on how to create sphinx extensions. Since e.g. blender uses sphinx too https://docs.blender.org/manual/en/dev/index.html , there probably would be others benefiting from this extension.

fabianr created this task.Aug 24 2018, 8:58 AM
fabianr moved this task from Backlog to Junior Jobs on the KDE Human Interface Guidelines board.
rmassabot claimed this task.EditedNov 27 2018, 1:58 AM
rmassabot added a subscriber: rmassabot.

I have made a tentative release for this here: https://github.com/sphinx-contrib/video

Please note that the sphinx extensions are now hosted on GitHub and not bitbucket anymore, although you are probably aware of this.

fabianr updated the task description. (Show Details)Nov 27 2018, 7:45 AM

Can I close this ticket then? Not sure about how the procedure goes :) I tested it locally with a demo sphinx deployment.

Hello,
first, thank you very much for looking into it!!
I'll try my best to find the time to try it today or on the weekend, and report back on monday.

I added

import os
import sys
sys.path.append(os.path.abspath('ext'))
extensions = ['sphinx.ext.todo', 'video']

to the conf.py

Unfortunately I get the following error:

File "/home/fabian/Projekte/HIG/.eggs/pbr-5.1.1-py3.6.egg/pbr/core.py", line 92, in pbr

'The setup.cfg file %s does not exist.' % path)

distutils.errors.DistutilsFileError: The setup.cfg file /home/fabian/Projekte/HIG/setup.cfg does not exist.

Anything else I must do?

Interesting, I'm on python 3.7.1, what version are you on?

Also, did you install the plugin correctly? Basically should be something like

git clone https://github.com/sphinx-contrib/video
cd video
sudo python setup.py install #or virtual env etc.

The setup.cfg seems to be something related to PBR which is a package used in sphinxcontrib.

Ok, after struggling a bit, I got it running :)

It seams that it the video source path is not rewritten in the same way as images are?

.. video:: /img/breadcrumb1.webm -> src="/img/breadcrumb1.webm"
.. image:: /img/IS-flat.png -> ../../_images/IS-flat.png

The video plugin is just a wrapper around the HTML5 tags, it does not rewrite anything as far as URL goes.

fabianr closed this task as Resolved.Dec 7 2018, 7:36 AM

Thank you very much again, for looking into this!

bshah added a subscriber: bshah.Dec 7 2018, 9:30 AM

@rmassabot

When using pip3 I get following error,

pip3 install git+https://github.com/sphinx-contrib/video
 ---> Running in 8841114426cf

Collecting git+https://github.com/sphinx-contrib/video
  Cloning https://github.com/sphinx-contrib/video to /tmp/pip-fnal8d9w-build

    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
        from setuptools.extern.six.moves import filterfalse, map
      File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
        @_call_aside
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
        f(*args, **kwargs)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
        add_activation_listener(lambda dist: dist.activate())
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
        callback(dist)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
        add_activation_listener(lambda dist: dist.activate())
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
        declare_namespace(pkg)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
        _handle_ns(packageName, path_item)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'

Can you suggest what to do?