A wagtail module for uploading and displaying videos in various codecs.
Project description
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 and also the ability to add and manage VTT text tracks for subtitles/captions.
Requirements
Wagtail >= 6.3 (for older wagtail version see the tags)
ffmpeg (optional, for transcoding)
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
Modify maximum file size:
Maximum file size that can be uploaded is defaulted to 1GB. This can be overriden using the WAGTAILVIDEOS_MAX_UPLOAD_SIZE setting
# settings.py
WAGTAILVIDEOS_MAX_UPLOAD_SIZE = 1024*1024*1024
Modify Thumbnail extension:
The automatically generated Thumbnail extension can be modified using the WAGTAIL_VIDEOS_THUMBNAIL_EXTENSION setting. Default value is jpg
# settings.py
WAGTAIL_VIDEOS_THUMBNAIL_EXTENSION = 'webp'
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')
)
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)
Future features
Some docs
Richtext embed
Transcoding via external service rather than ffmpeg
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtailvideos-7.2.0.tar.gz.
File metadata
- Download URL: wagtailvideos-7.2.0.tar.gz
- Upload date:
- Size: 82.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abd2846eb4f38b76d7efc34691d5e9f12dc86431fabeb244b2dba26b9c9d676
|
|
| MD5 |
56cbdd1a4367d25978d601cc3430b84f
|
|
| BLAKE2b-256 |
04fc7d929eb69b25226c1e55d4697585ef1685bcba3f1e45e4e300c025783495
|
Provenance
The following attestation bundles were made for wagtailvideos-7.2.0.tar.gz:
Publisher:
release.yml on neon-jungle/wagtail-videos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtailvideos-7.2.0.tar.gz -
Subject digest:
5abd2846eb4f38b76d7efc34691d5e9f12dc86431fabeb244b2dba26b9c9d676 - Sigstore transparency entry: 868932552
- Sigstore integration time:
-
Permalink:
neon-jungle/wagtail-videos@26e43111a11c41d484106bc2e7debae08dc41cc6 -
Branch / Tag:
refs/tags/7.2.0 - Owner: https://github.com/neon-jungle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@26e43111a11c41d484106bc2e7debae08dc41cc6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wagtailvideos-7.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: wagtailvideos-7.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 111.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25332d40299a74020e546243eb97cf443b733bb97a74c716238e363e69e66a48
|
|
| MD5 |
cbb98d0b59cf719fe2656669ccc6b197
|
|
| BLAKE2b-256 |
0a7ab1549db652355ab51df87791e1f3acc4381c8df70fb117b231548c033eeb
|
Provenance
The following attestation bundles were made for wagtailvideos-7.2.0-py2.py3-none-any.whl:
Publisher:
release.yml on neon-jungle/wagtail-videos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtailvideos-7.2.0-py2.py3-none-any.whl -
Subject digest:
25332d40299a74020e546243eb97cf443b733bb97a74c716238e363e69e66a48 - Sigstore transparency entry: 868932554
- Sigstore integration time:
-
Permalink:
neon-jungle/wagtail-videos@26e43111a11c41d484106bc2e7debae08dc41cc6 -
Branch / Tag:
refs/tags/7.2.0 - Owner: https://github.com/neon-jungle
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@26e43111a11c41d484106bc2e7debae08dc41cc6 -
Trigger Event:
push
-
Statement type: