Make the video encoding user configurable
This commit is contained in:
@@ -291,7 +291,8 @@ def process_video(filepath, outpath, settings):
|
||||
shutil.copy(filepath, join(outpath, settings['orig_dir'], filename))
|
||||
|
||||
# TODO: Add specific video size settings
|
||||
sigal.video.generate_video(filepath, outname, settings['img_size'])
|
||||
sigal.video.generate_video(filepath, outname, settings['img_size'],
|
||||
settings['webm_options'])
|
||||
|
||||
if settings['make_thumbs']:
|
||||
thumb_name = join(outpath, get_thumb(settings, filename))
|
||||
|
||||
@@ -37,6 +37,7 @@ _DEFAULT_CONFIG = {
|
||||
'keep_orig': False,
|
||||
'orig_dir': 'original',
|
||||
'jpg_options': {'quality': 85, 'optimize': True, 'progressive': True},
|
||||
'webm_options': {'crf': '10', 'bitrate': '1.6M', 'qmin': '4', 'qmax': '63'},
|
||||
'copyright': '',
|
||||
'img_ext_list': ['.jpg', '.jpeg', '.JPG', '.JPEG', '.png'],
|
||||
'vid_ext_list': ['.MOV', '.mov', '.avi', '.mp4', '.webm', '.ogv'],
|
||||
|
||||
@@ -16,7 +16,7 @@ source = 'pictures'
|
||||
# - colorbox (default), galleria, or the path to a custom theme directory
|
||||
theme = 'galleria'
|
||||
|
||||
# Size of resized image
|
||||
# Size of resized image (default: (640, 480))
|
||||
img_size = (800, 600)
|
||||
|
||||
# Pilkit processor used to resize the image
|
||||
@@ -55,6 +55,16 @@ thumb_size = (280, 210)
|
||||
# 'optimize': True,
|
||||
# 'progressive': True}
|
||||
|
||||
# Webm options
|
||||
# Options used in ffmpeg to encode the webm video. You may want to read
|
||||
# http://ffmpeg.org/trac/ffmpeg/wiki/vpxEncodingGuide
|
||||
# Be aware of the fact these options need to be passed as strings.
|
||||
# webm_options = {'crf': '10',
|
||||
# 'bitrate': '1.6M',
|
||||
# 'qmin': '4',
|
||||
# 'qmax': '63'}
|
||||
|
||||
|
||||
# Write HTML files. If False, sigal will only process the images.
|
||||
# write_html = True
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import subprocess
|
||||
import os
|
||||
import sigal.image
|
||||
|
||||
def generate_video(source, outname, size, options=[]):
|
||||
def generate_video(source, outname, size, options={}):
|
||||
"""Video processor
|
||||
|
||||
:param source: path to an image
|
||||
@@ -42,9 +42,13 @@ def generate_video(source, outname, size, options=[]):
|
||||
# http://ffmpeg.org/trac/ffmpeg/wiki/vpxEncodingGuide
|
||||
(w, h) = size
|
||||
with open("/dev/null") as devnull:
|
||||
subprocess.call(['ffmpeg', '-i', source, '-y', '-crf', '10',
|
||||
'-b:v', '1.6M','-vf', "scale=%i:trunc(ow/a/2)*2'" % w] +
|
||||
options + [outname], stderr=devnull)
|
||||
subprocess.call(['ffmpeg', '-i', source, '-y',
|
||||
'-crf', options.get('crf', '10'),
|
||||
'-b:v', options.get('bitrate', '1.6M'),
|
||||
'-qmin', options.get('qmin', '4'),
|
||||
'-qmax',options.get('qmax', '63'),
|
||||
'-vf', "scale=%i:trunc(ow/a/2)*2'" % w,
|
||||
outname], stderr=devnull)
|
||||
|
||||
def generate_thumbnail(source, outname, box, format, fit=True, options=None):
|
||||
"Create a thumbnail image"
|
||||
|
||||
Reference in New Issue
Block a user