Browse Source

Added the video_format and mp4_settings settings in the settings template (sigal/templates/sigal.conf.py), added myself to the AUTHORS file. Parametrized the tests/test_video.py tests to run both for webm & mp4.

pull/159/head
Miroslav Pavleski 11 years ago
parent
commit
3a614759cb
  1. 1
      AUTHORS
  2. 9
      sigal/templates/sigal.conf.py
  3. 35
      tests/test_video.py

1
AUTHORS

@ -14,6 +14,7 @@ alphabetical order):
- Keith Johnson
- Lukas Vacek
- Matthias Vogelgesang
- Miroslav Pavleski
- Nicolas Arnaud-Cormos
- Nikolai Prokoschenko
- @phaer

9
sigal/templates/sigal.conf.py

@ -122,6 +122,10 @@ ignore_files = []
# 'optimize': True,
# 'progressive': True}
# Video format
# specify an alternative format, valid are 'webm' (default) and 'mp4'
# video_format = 'webm'
# Webm options
# Options used in ffmpeg to encode the webm video. You may want to read
# http://ffmpeg.org/trac/ffmpeg/wiki/vpxEncodingGuide
@ -130,6 +134,11 @@ ignore_files = []
# webm_options = ['-crf', '10', '-b:v', '1.6M',
# '-qmin', '4', '-qmax', '63']
# MP4 options
# Options used to encode the mp4 video. You may want to read
# https://trac.ffmpeg.org/wiki/Encode/H.264
# mp4_options = ['-crf', '23' ]
# Size of resized video (default: (480, 360))
# video_size = (480, 360)

35
tests/test_video.py

@ -3,6 +3,7 @@
from __future__ import division
import os
import pytest
from sigal.video import video_size, generate_video
from sigal.settings import create_settings
@ -16,13 +17,16 @@ def test_video_size():
size_src = video_size(SRCFILE)
assert size_src == (480, 270)
def test_generate_video_fit_height(tmpdir):
@pytest.mark.parametrize("fmt", [
('webm'),
('mp4')
])
def test_generate_video_fit_height(tmpdir, fmt):
"""largest fitting dimension is height"""
base, ext = os.path.splitext(TEST_VIDEO)
dstfile = str(tmpdir.join(base + '.webm'))
settings = create_settings(video_size=(50, 100))
dstfile = str(tmpdir.join(base + '.' + fmt))
settings = create_settings(video_size=(50, 100), video_format=fmt)
generate_video(SRCFILE, dstfile, settings)
size_src = video_size(SRCFILE)
@ -32,13 +36,16 @@ def test_generate_video_fit_height(tmpdir):
# less than 2% error on ratio
assert abs(size_dst[0]/size_dst[1] - size_src[0]/size_src[1]) < 2e-2
def test_generate_video_fit_width(tmpdir):
@pytest.mark.parametrize("fmt", [
('webm'),
('mp4')
])
def test_generate_video_fit_width(tmpdir, fmt):
"""largest fitting dimension is width"""
base, ext = os.path.splitext(TEST_VIDEO)
dstfile = str(tmpdir.join(base + '.webm'))
settings = create_settings(video_size=(100, 50))
dstfile = str(tmpdir.join(base + '.' + fmt))
settings = create_settings(video_size=(100, 50), video_format=fmt)
generate_video(SRCFILE, dstfile, settings)
size_src = video_size(SRCFILE)
@ -48,15 +55,17 @@ def test_generate_video_fit_width(tmpdir):
# less than 2% error on ratio
assert abs(size_dst[0]/size_dst[1] - size_src[0]/size_src[1]) < 2e-2
def test_generate_video_dont_enlarge(tmpdir):
@pytest.mark.parametrize("fmt", [
('webm'),
('mp4')
])
def test_generate_video_dont_enlarge(tmpdir, fmt):
"""video dimensions should not be enlarged"""
base, ext = os.path.splitext(TEST_VIDEO)
dstfile = str(tmpdir.join(base + '.webm'))
settings = create_settings(video_size=(1000, 1000))
dstfile = str(tmpdir.join(base + '.' + fmt))
settings = create_settings(video_size=(1000, 1000), video_format=fmt)
generate_video(SRCFILE, dstfile, settings)
size_src = video_size(SRCFILE)
size_dst = video_size(dstfile)

Loading…
Cancel
Save