Browse Source

Recommended fixes

Using video_size = None to prevent resizing instead of another option
Eliminating pointless method for just getting resize_dimensions
pull/420/head
Keith Feldman 5 years ago
parent
commit
76bc8afe89
  1. 1
      sigal/settings.py
  2. 5
      sigal/templates/sigal.conf.py
  3. 27
      sigal/video.py

1
sigal/settings.py

@ -80,7 +80,6 @@ _DEFAULT_CONFIG = {
'video_converter': 'ffmpeg',
'video_extensions': ['.mov', '.avi', '.mp4', '.webm', '.ogv', '.3gp'],
'video_format': 'webm',
'video_resize': True,
'video_always_convert': False,
'video_size': (480, 360),
'watermark': '',

5
sigal/templates/sigal.conf.py

@ -189,6 +189,7 @@ ignore_files = []
# Size of resized video (default: (480, 360))
# Set this to None if no resizing is desired on the video.
# video_size = (480, 360)
# If the desired video extension and filename are the same, the video will
@ -196,10 +197,6 @@ ignore_files = []
# set this to True to force convert it. False by default.
# video_always_convert = False
# Set this to false if no resizing is desired on the video. This overrides
# the video_size option.
# video_resize = True
# -------------
# Miscellaneous
# -------------

27
sigal/video.py

@ -77,33 +77,17 @@ def video_size(source, converter='ffmpeg'):
x, y = y, x
return x, y
def get_dimensions(source, converter, output_size):
"""Figure out src and dest width and height for video.
def get_resize_options(source, converter, output_size):
"""Figure out resize options for video from src and dst sizes.
:param source: path to a video
:param outname: path to the generated video
:param settings: settings dict
"""
logger = logging.getLogger(__name__)
# Don't transcode if source is in the required format and
# has fitting datedimensions, copy instead.
w_src, h_src = video_size(source, converter=converter)
w_dst, h_dst = output_size
logger.debug('Video size: %i, %i -> %i, %i', w_src, h_src, w_dst, h_dst)
return {'src': (w_src, h_src), 'dst': (w_dst, h_dst)}
def get_resize_options(src_dst_dimension_dict):
"""Figure out resize options for video from src and dst sizes.
:param src_dst_dimension_dict: a dictionary of src and dst,
each with a width, height tuple
"""
w_src, h_src = src_dst_dimension_dict['src']
w_dst, h_dst = src_dst_dimension_dict['dst']
# do not resize if input dimensions are smaller than output dimensions
if w_src <= w_dst and h_src <= h_dst:
@ -160,10 +144,9 @@ def generate_video(source, outname, settings):
converter = settings['video_converter']
resize_opt = []
if settings.get("video_resize"):
src_dst_dimension_dict = get_dimensions(source, converter,
settings['video_size'])
resize_opt = get_resize_options(src_dst_dimension_dict)
if settings.get("video_size"):
resize_opt = get_resize_options(source, converter,
settings['video_size'])
base, src_ext = splitext(source)
base, dst_ext = splitext(outname)

Loading…
Cancel
Save