Browse Source

added support for mp4, manually tested, mp4 files transcoded and links correctly populated in html

pull/159/head
Miroslav Pavleski 11 years ago
parent
commit
01d442d3ef
  1. 10
      sigal/gallery.py
  2. 2
      sigal/plugins/upload_s3.py
  3. 2
      sigal/settings.py
  4. 10
      sigal/video.py

10
sigal/gallery.py

@ -181,9 +181,13 @@ class Video(Media):
self.date = None
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')
video_format = settings['video_format']
ext = '.' + video_format
self.filename = self.url = base + ext
self.mime = get_mime(ext)
self.dst_path = join(settings['destination'], path, base + ext)
else:
self.mime = get_mime(ext)

2
sigal/plugins/upload_s3.py

@ -72,7 +72,7 @@ def generate_cache_metadata(gallery, f):
proposed_cache_control = None
if 'media_max_age' in gallery.settings['upload_s3_options'] and \
file_extension in ['.jpg','.png','.webm']:
file_extension in ['.jpg','.png','.webm','.mp4']:
proposed_cache_control = "max-age=%s" % \
gallery.settings['upload_s3_options']['media_max_age']
elif 'max_age' in gallery.settings['upload_s3_options']:

2
sigal/settings.py

@ -67,8 +67,10 @@ _DEFAULT_CONFIG = {
'use_orig': False,
'video_size': (480, 360),
'watermark': '',
'video_format': 'webm',
'webm_options': ['-crf', '10', '-b:v', '1.6M',
'-qmin', '4', '-qmax', '63'],
'mp4_options': ['-crf', '23' ],
'write_html': True,
'zip_gallery': False,
'zip_media_format': 'resized',

10
sigal/video.py

@ -156,9 +156,15 @@ def process_video(filepath, outpath, settings):
outname = os.path.join(outpath, filename)
utils.copy(filepath, outname, symlink=settings['orig_link'])
else:
outname = os.path.join(outpath, basename + '.webm')
valid_formats = ['mp4', 'webm']
video_format = settings['video_format']
if video_format not in valid_formats:
raise ValueError('Invalid video_format. Please choose one of: ' + str(valid_formats))
outname = os.path.join(outpath, basename + '.' + video_format)
generate_video(filepath, outname, settings,
options=settings['webm_options'])
options=settings[video_format + '_options'])
except Exception:
return Status.FAILURE

Loading…
Cancel
Save