Set HTML5 video type correctly
As we can use the videos as they are, without conversion, we need to set the video type correctly.
This commit is contained in:
@@ -44,7 +44,8 @@ from .compat import PY2, UnicodeMixin, strxfrm, url_quote, text_type
|
||||
from .image import process_image, get_exif_tags, get_exif_data
|
||||
from .settings import get_thumb
|
||||
from .utils import (Devnull, copy, check_or_create_dir, url_from_path,
|
||||
read_markdown, cached_property, is_valid_html5_video)
|
||||
read_markdown, cached_property, is_valid_html5_video,
|
||||
get_mime)
|
||||
from .video import process_video
|
||||
from .writer import Writer
|
||||
|
||||
@@ -181,7 +182,10 @@ class Video(Media):
|
||||
self.src_filename = filename
|
||||
if not settings['use_orig'] or not is_valid_html5_video(ext):
|
||||
self.filename = self.url = base + '.webm'
|
||||
self.mime = get_mime('.webm')
|
||||
self.dst_path = join(settings['destination'], path, base + '.webm')
|
||||
else:
|
||||
self.mime = get_mime(ext)
|
||||
|
||||
|
||||
class Album(UnicodeMixin):
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<div style='display:none'>
|
||||
<div id="{{ mhash }}">
|
||||
<video controls>
|
||||
<source src='{{ media.filename }}' type='video/webm' />
|
||||
<source src='{{ media.filename }}' type='{{ media.mime }}' />
|
||||
</video>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -103,6 +103,13 @@ def is_valid_html5_video(ext):
|
||||
"""Checks if ext is a supported HTML5 video."""
|
||||
return ext in ('.mp4', '.webm', '.ogv')
|
||||
|
||||
def get_mime(ext):
|
||||
"""Returns mime type for extension."""
|
||||
mimes = {'.mp4': 'video/mp4',
|
||||
'.webm': 'video/webm',
|
||||
'.ogv': 'video/ogg'}
|
||||
return mimes[ext]
|
||||
|
||||
class cached_property(object):
|
||||
""" A property that is only computed once per instance and then replaces
|
||||
itself with an ordinary attribute. Deleting the attribute resets the
|
||||
|
||||
Reference in New Issue
Block a user