Unverified Commit c281c46a authored by seb-b's avatar seb-b Committed by GitHub
Browse files

Merge pull request #74 from jkevingutierrez/patch-3

Add ability to disable transcode
parents 430f500d 1ac08ae2
...@@ -62,7 +62,7 @@ In a Streamfield: ...@@ -62,7 +62,7 @@ In a Streamfield:
A VideoChooserBlock is included A VideoChooserBlock is included
.. code:: python .. code:: python
from wagtail.admin.edit_handlers import StreamFieldPanel from wagtail.admin.edit_handlers import StreamFieldPanel
from wagtail.core.fields import StreamField from wagtail.core.fields import StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
...@@ -103,10 +103,21 @@ be used to create new transcodes. It is assumed that your compiled ...@@ -103,10 +103,21 @@ be used to create new transcodes. It is assumed that your compiled
version of ffmpeg has the matching codec libraries required for the version of ffmpeg has the matching codec libraries required for the
transcode. transcode.
Disable transcode:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Transcode can be disabled using the ``WAGTAIL_VIDEOS_DISABLE_TRANSCODE`` setting.
.. code:: django
# settings.py
WAGTAIL_VIDEOS_DISABLE_TRANSCODE = True
Custom Video models: Custom Video models:
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Same as Wagtail Images, a custom model can be used to replace the built in Video model using the Same as Wagtail Images, a custom model can be used to replace the built in Video model using the
``WAGTAILVIDEOS_VIDEO_MODEL`` setting. ``WAGTAILVIDEOS_VIDEO_MODEL`` setting.
.. code:: django .. code:: django
...@@ -138,7 +149,7 @@ Same as Wagtail Images, a custom model can be used to replace the built in Video ...@@ -138,7 +149,7 @@ Same as Wagtail Images, a custom model can be used to replace the built in Video
unique_together = ( unique_together = (
('video', 'media_format') ('video', 'media_format')
) )
# Only needed if you are using the text tracks feature # Only needed if you are using the text tracks feature
class CustomTrackListing(AbstractTrackListing): class CustomTrackListing(AbstractTrackListing):
video = models.OneToOneField(AttributedVideo, related_name='track_listing', on_delete=models.CASCADE) video = models.OneToOneField(AttributedVideo, related_name='track_listing', on_delete=models.CASCADE)
......
from django.apps import AppConfig from django.apps import AppConfig
from django.conf import settings
from django.core.checks import Warning, register from django.core.checks import Warning, register
from wagtailvideos import ffmpeg from wagtailvideos import ffmpeg
...@@ -6,7 +7,10 @@ from wagtailvideos import ffmpeg ...@@ -6,7 +7,10 @@ from wagtailvideos import ffmpeg
def ffmpeg_check(app_configs, **kwargs): def ffmpeg_check(app_configs, **kwargs):
messages = [] messages = []
if not ffmpeg.installed(): if (
not ffmpeg.installed()
and not getattr(settings, 'WAGTAIL_VIDEOS_DISABLE_TRANSCODE', False)
):
messages.append( messages.append(
Warning( Warning(
'ffmpeg could not be found on your system. Transcoding will be disabled', 'ffmpeg could not be found on your system. Transcoding will be disabled',
......
...@@ -51,15 +51,15 @@ ...@@ -51,15 +51,15 @@
</form> </form>
</div> </div>
<div class="col6"> <div class="col6">
<div class='row'> <div class="row">
<div class='col10 divider-after'> <div class="col10 divider-after">
{% video video controls style=max-width:100%;width:100%;height:auto; %} {% video video controls style=max-width:100%;width:100%;height:auto; %}
</div> </div>
<div class='col2'> <div class="col2">
<dl style='margin-top: 0'> <dl style="margin-top: 0;">
{% if video.thumbnail %} {% if video.thumbnail %}
<dt>{% trans "Thumbnail" %}</dt> <dt>{% trans "Thumbnail" %}</dt>
<dd><img src="{{ video.thumbnail.url }}" /></dd> <dd><img src="{{ video.thumbnail.url }}" alt="{% trans 'Video thumbnail' %}" /></dd>
{% endif %} {% endif %}
<dt>{% trans "Filesize" %}</dt> <dt>{% trans "Filesize" %}</dt>
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd> <dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</dl> </dl>
</div> </div>
</div> </div>
<div class="row" style='margin-top: 2em;'> <div class="row" style="margin-top: 2em;">
{% if can_transcode %} {% if can_transcode %}
<h2 class="u-text-transform-uppercase">{% trans "Transcodes" %}</h2> <h2 class="u-text-transform-uppercase">{% trans "Transcodes" %}</h2>
<p>{% trans "If you wish to generate HTML5 compliant transcodes use the form below. This may take a while depending on the length of the video." %}</p> <p>{% trans "If you wish to generate HTML5 compliant transcodes use the form below. This may take a while depending on the length of the video." %}</p>
...@@ -88,11 +88,11 @@ ...@@ -88,11 +88,11 @@
<li> <li>
{% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{{ media_format }} ({{ quality }} quality){% endblocktrans %} {% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{{ media_format }} ({{ quality }} quality){% endblocktrans %}
{% if transcode.processing %} {% if transcode.processing %}
<span class='processing'>{% trans "(Processing... hold tight)" %} </span> <span class="processing">{% trans "(Processing... hold tight)" %} </span>
{% endif %} {% endif %}
{% if transcode.error_message %} {% if transcode.error_message %}
<span class='transcode-error'>{% trans "ERROR:" %}</span> <span class="transcode-error">{% trans "ERROR:" %}</span>
<div class='transcode-error'> <div class="transcode-error">
<pre> {{ transcode.error_message }}</pre> <pre> {{ transcode.error_message }}</pre>
</div> </div>
{% endif %} {% endif %}
...@@ -107,13 +107,13 @@ ...@@ -107,13 +107,13 @@
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %} {% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %} {% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
<li> <li>
<input class="button" type='submit' value="{% trans 'Start' %}" /> <input class="button" type="submit" value="{% trans 'Start' %}" />
</li> </li>
</ul> </ul>
</form> </form>
{% else %} {% else %}
<br/><br/> <br/><br/>
<span class='transcode-error'>{% trans "Ffmpeg is not found on your server. Please install if you wish to transcode videos into an HTML5 video compliant format." %}</span> <span class="transcode-error">{% trans "Ffmpeg is not found on your server or you have disabled transcodes. Please install Ffmepg and make sure that transcoding is enabled if you wish to transcode videos into an HTML5 video compliant format." %}</span>
{% endif %} {% endif %}
{% if tracks_action_url %} {% if tracks_action_url %}
<h2 class="u-text-transform-uppercase">{% trans "Tracks" %}</h2> <h2 class="u-text-transform-uppercase">{% trans "Tracks" %}</h2>
...@@ -124,9 +124,9 @@ ...@@ -124,9 +124,9 @@
<li>{{ track }}</li> <li>{{ track }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
<a class='button' href="{{ tracks_action_url }}">{% trans "Edit" %}</a> <a class="button" href="{{ tracks_action_url }}">{% trans "Edit" %}</a>
{% else %} {% else %}
<a class='button' href="{{ tracks_action_url }}">{% trans "Add tracks" %}</a> <a class="button" href="{{ tracks_action_url }}">{% trans "Add tracks" %}</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
......
from distutils.version import LooseVersion from distutils.version import LooseVersion
import wagtail import wagtail
from django.conf import settings
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse from django.urls import reverse
...@@ -130,7 +131,7 @@ def edit(request, video_id): ...@@ -130,7 +131,7 @@ def edit(request, video_id):
'video': video, 'video': video,
'form': form, 'form': form,
'filesize': video.get_file_size(), 'filesize': video.get_file_size(),
'can_transcode': ffmpeg.installed(), 'can_transcode': ffmpeg.installed() and not getattr(settings, 'WAGTAIL_VIDEOS_DISABLE_TRANSCODE', False),
'transcodes': video.transcodes.all(), 'transcodes': video.transcodes.all(),
'transcode_form': VideoTranscodeAdminForm(video=video), 'transcode_form': VideoTranscodeAdminForm(video=video),
'tracks_action_url': action_url, 'tracks_action_url': action_url,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment