Commit e998fd3b authored by Seb's avatar Seb
Browse files

Added ffmpeg check for edit screen, disabled transcoding if not there

parent 69785b13
......@@ -28,6 +28,8 @@ from wagtail.wagtailcore.models import CollectionMember
from wagtail.wagtailsearch import index
from wagtail.wagtailsearch.queryset import SearchableQuerySetMixin
from wagtailvideos.utils import ffmpeg_installed
logger = logging.getLogger(__name__)
......@@ -149,6 +151,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
if self.duration:
return self.duration
if not ffmpeg_installed():
return None
file_path = self.file.path
try:
# FIXME prints out extra stuff on travis, pip stderr to dev/null
......@@ -165,6 +170,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
if self.thumbnail:
return self.thumbnail
if not ffmpeg_installed():
return None
file_path = self.file.path
file_name = self.filename(include_ext=False) + '_thumb.jpg'
......
......@@ -27,6 +27,7 @@
</div>
<div class="col5 divider-after">
<h2 class="label">{% trans "Video preview" %}</h2> {% video video controls style=max-width:100% %}
{% if can_transcode %}
<h3 class="label">Transcodes</h3>
<p>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>
{% if transcodes %}
......@@ -53,15 +54,20 @@
</li>
</ul>
</form>
{% endif %}
</div>
<div class="col2 ">
<dl>
{% if video.thumbnail %}
<dt>{% trans "Thumbnail" %}</dt>
<dd><img src='{{ video.thumbnail.url }}' /></dd>
{% endif %}
<dt>{% trans "Filesize" %}</dt>
<dd>{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}</dd>
{% if video.duration %}
<dt>{% trans "Duration" %}</dt>
<dd>{{ video.formatted_duration }}</dd>
{% endif %}
</dl>
</div>
</div>
......
......@@ -17,6 +17,7 @@ from wagtail.wagtailsearch.backends import get_search_backends
from wagtailvideos.forms import VideoTranscodeAdminForm, get_video_form
from wagtailvideos.models import Video
from wagtailvideos.permissions import permission_policy
from wagtailvideos.utils import ffmpeg_installed
permission_checker = PermissionPolicyChecker(permission_policy)
......@@ -69,6 +70,7 @@ def index(request):
})
return response
@permission_checker.require('change')
def edit(request, video_id):
VideoForm = get_video_form(Video)
......@@ -117,12 +119,12 @@ def edit(request, video_id):
'video': video,
'form': form,
'filesize': video.get_file_size(),
'can_transcode': ffmpeg_installed(),
'transcodes': video.transcodes.all(),
'transcode_form': VideoTranscodeAdminForm(video=video),
'user_can_delete': permission_policy.user_has_permission_for_instance(request.user, 'delete', video)
})
def create_transcode(request, video_id):
if request.method != 'POST':
return HttpResponseNotAllowed(['POST'])
......
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