From 3a614759cbd78aad8c52a5d321f56f0faff25c12 Mon Sep 17 00:00:00 2001 From: Miroslav Pavleski Date: Tue, 26 May 2015 23:05:40 +0200 Subject: [PATCH] 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. --- AUTHORS | 1 + sigal/templates/sigal.conf.py | 9 +++++++++ tests/test_video.py | 35 ++++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/AUTHORS b/AUTHORS index 30d99e0..215c7da 100644 --- a/AUTHORS +++ b/AUTHORS @@ -14,6 +14,7 @@ alphabetical order): - Keith Johnson - Lukas Vacek - Matthias Vogelgesang +- Miroslav Pavleski - Nicolas Arnaud-Cormos - Nikolai Prokoschenko - @phaer diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index 752e5b1..dabf9f4 100644 --- a/sigal/templates/sigal.conf.py +++ b/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) diff --git a/tests/test_video.py b/tests/test_video.py index 61eda75..2841052 100644 --- a/tests/test_video.py +++ b/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)