Skip to main content

A wagtail module for uploading and displaying videos in various codecs.

Project description

https://gitlab.com/neonjungle/wagtailvideos/badges/master/pipeline.svg

Based on wagtailimages. The aim was to have feature parity with images but for html5 videos. Includes the ability to transcode videos to a html5 compliant codec using ffmpeg.

Requirements

Installing

Install using pypi

pip install wagtailvideos

Add wagtailvideos to your installed apps.

INSTALLED_APPS = [
    'wagtailvideos',
]

Using

On a page model:

Implement as a ForeignKey relation, same as wagtailimages.

from django.db import models

from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page

from wagtailvideos.edit_handlers import VideoChooserPanel


class HomePage(Page):
    body = RichtextField()
    header_video = models.ForeignKey('wagtailvideos.Video',
                                     related_name='+',
                                     null=True,
                                     on_delete=models.SET_NULL)

    content_panels = Page.content_panels + [
        FieldPanel('body'),
        VideoChooserPanel('header_video'),
    ]

In a Streamfield:

A VideoChooserBlock is included

from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core.fields import StreamField
from wagtail.core.models import Page

from wagtailvideos.blocks import VideoChooserBlock


class ContentPage(Page):
  body = StreamField([
      ('video', VideoChooserBlock()),
  ])

  content_panels = Page.content_panels + [
      StreamFieldPanel('body'),
  ]

In template:

The video template tag takes one required postitional argument, a video field. All extra attributes are added to the surrounding <video> tag. The original video and all extra transcodes are added as <source> tags.

{% load wagtailvideos_tags %}
{% video self.header_video autoplay controls width=256 %}

Jinja2 extensions are also included.

How to transcode using ffmpeg:

Using the video collection manager from the left hand menu. In the video editing section you can see the available transcodes and a form that can be used to create new transcodes. It is assumed that your compiled version of ffmpeg has the matching codec libraries required for the transcode.

Disable transcode:

Transcode can be disabled using the WAGTAIL_VIDEOS_DISABLE_TRANSCODE setting.

# settings.py
WAGTAIL_VIDEOS_DISABLE_TRANSCODE = True

Custom Video models:

Same as Wagtail Images, a custom model can be used to replace the built in Video model using the WAGTAILVIDEOS_VIDEO_MODEL setting.

# settings.py
WAGTAILVIDEOS_VIDEO_MODEL = 'videos.AttributedVideo'

# app.videos.models
from django.db import models
from modelcluster.fields import ParentalKey
from wagtailvideos.models import AbstractVideo, AbstractVideoTranscode

class AttributedVideo(AbstractVideo):
    attribution = models.TextField()

    admin_form_fields = (
        'title',
        'attribution',
        'file',
        'collection',
        'thumbnail',
        'tags',
    )

class CustomTranscode(AbstractVideoTranscode):
    video = models.ForeignKey(AttributedVideo, related_name='transcodes', on_delete=models.CASCADE)

    class Meta:
        unique_together = (
            ('video', 'media_format')
        )

# Only needed if you are using the text tracks feature
class CustomTrackListing(AbstractTrackListing):
    video = models.OneToOneField(AttributedVideo, related_name='track_listing', on_delete=models.CASCADE)

class CustomVideoTrack(AbstractVideoTrack):
    listing = ParentalKey(CustomTrackListing, related_name='tracks', on_delete=models.CASCADE)

Video text tracks:

To enable the uploading and displaying of VTT tracks (e.g. subtitles, captions) you’ll need to add wagtail.contrib.modeladmin to your installed apps. Once added, there will be an new area in the admin for attaching VTT files to videos with associaled metadata.

Future features

  • Some docs

  • Richtext embed

  • Transcoding via amazon service rather than ffmpeg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtailvideos-2.10.8.tar.gz (58.8 kB view details)

Uploaded Source

Built Distribution

wagtailvideos-2.10.8-py2.py3-none-any.whl (83.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wagtailvideos-2.10.8.tar.gz.

File metadata

  • Download URL: wagtailvideos-2.10.8.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for wagtailvideos-2.10.8.tar.gz
Algorithm Hash digest
SHA256 cce62d63dd9db365820af6cfd21a22b59c5caebb63680ace6664f905c92b6bee
MD5 7a63b370f6b1cafb033d2289993892cc
BLAKE2b-256 346ebefd711601547bbd9f104da3cda2ad2e272c12d4323e19120fc713a69fe0

See more details on using hashes here.

File details

Details for the file wagtailvideos-2.10.8-py2.py3-none-any.whl.

File metadata

  • Download URL: wagtailvideos-2.10.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 83.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for wagtailvideos-2.10.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a141a4f266a339ced559896156b5336f9a65681e8c125c7ee16d892964e23784
MD5 d18ab28c751b078a5777da91c538312c
BLAKE2b-256 1c5f1146c3f5d383323bb95bf523a076f1b419fef1d78ecec37e9b1deb7d95b8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page