From 409c7b3110ff0d6c4629f810e5a887e3ef213f1d Mon Sep 17 00:00:00 2001 From: "v.paritskiy" Date: Wed, 20 Apr 2016 18:16:09 +0300 Subject: [PATCH 01/10] Concatenate: set mask duration to clip duration --- moviepy/video/compositing/concatenate.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/moviepy/video/compositing/concatenate.py b/moviepy/video/compositing/concatenate.py index 358a93149..82d8354b8 100644 --- a/moviepy/video/compositing/concatenate.py +++ b/moviepy/video/compositing/concatenate.py @@ -83,12 +83,15 @@ def make_frame(t): i = max([i for i, e in enumerate(tt) if e <= t]) return clips[i].get_frame(t - tt[i]) + def get_mask(c): + mask = c.mask or ColorClip([1, 1], col=1, ismask=True) + if mask.duration is None: + mask.duration = c.duration + return mask + result = VideoClip(ismask = ismask, make_frame = make_frame) if any([c.mask is not None for c in clips]): - masks = [c.mask if (c.mask is not None) else - ColorClip([1,1], col=1, ismask=True, duration=c.duration) - #ColorClip(c.size, col=1, ismask=True).set_duration(c.duration) - for c in clips] + masks = [get_mask(c) for c in clips] result.mask = concatenate_videoclips(masks, method="chain", ismask=True) result.clips = clips From ba9c2d07c0e112d280bc372e1e4febbbde2d656b Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 10:13:47 -0500 Subject: [PATCH 02/10] add matplotlib test --- tests/test_examples.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test_examples.py diff --git a/tests/test_examples.py b/tests/test_examples.py new file mode 100644 index 000000000..759ffb722 --- /dev/null +++ b/tests/test_examples.py @@ -0,0 +1,36 @@ +import pytest +from moviepy.editor import * +import moviepy.video.tools.cuts as cuts + +import sys +sys.path.append("tests") +import download_media + +def test_download_media(capsys): + with capsys.disabled(): + download_media.download() + +def test_matplotlib(): + import matplotlib.pyplot as plt + import numpy as np + from moviepy.editor import VideoClip + from moviepy.video.io.bindings import mplfig_to_npimage + + x = np.linspace(-2, 2, 200) + + duration = 2 + + fig, ax = plt.subplots() + + def make_frame(t): + ax.clear() + ax.plot(x, np.sinc(x**2) + np.sin(x + 2*np.pi/duration * t), lw=3) + ax.set_ylim(-1.5, 2.5) + return mplfig_to_npimage(fig) + + animation = VideoClip(make_frame, duration=duration) + animation.write_gif('/tmp/matplotlib.gif', fps=20) + + +if __name__ == '__main__': + pytest.main() From 87c07fe4749dfbc9e59d49e01e79e03b193decef Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 10:20:19 -0500 Subject: [PATCH 03/10] add python version test --- tests/test_examples.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_examples.py b/tests/test_examples.py index 759ffb722..62a3f5a73 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -11,6 +11,9 @@ def test_download_media(capsys): download_media.download() def test_matplotlib(): + if sys.version_info < (3,4): + return + import matplotlib.pyplot as plt import numpy as np from moviepy.editor import VideoClip From 7457c84da958757448306900e3d962c362f4b774 Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 10:39:37 -0500 Subject: [PATCH 04/10] output display variable --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index efeaef852..469325b20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ install: - python setup.py install # command to run tests before_script: + - echo $DISPLAY - py.test tests/ --cov script: py.test tests/ --doctest-modules -v --cov moviepy --cov-report term-missing after_success: From 3bbb4f3b6d1ef72505b9463c10fde0d1a2732908 Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 10:49:58 -0500 Subject: [PATCH 05/10] set matplotlib == 2.0.0 since 2.0.1 causes :0 error under python 3.5 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 469325b20..c2347ebbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_install: - sudo apt-get install -y ffmpeg - mkdir media install: - - if [[ $TRAVIS_PYTHON_VERSION == '3.4' || $TRAVIS_PYTHON_VERSION == '3.5' || $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install matplotlib; pip install -U scikit-learn; pip install scipy; fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.4' || $TRAVIS_PYTHON_VERSION == '3.5' || $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install matplotlib==2.0.0; pip install -U scikit-learn; pip install scipy; fi - pip install coveralls - pip install pytest-cov - python setup.py install From d7a5b829ac5cd9c7d85cbdd7dea6dc51ddaf906b Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 11:01:16 -0500 Subject: [PATCH 06/10] in py 3.5 ignore matplotlib example --- tests/test_examples.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 62a3f5a73..9cb1fb9db 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -11,7 +11,9 @@ def test_download_media(capsys): download_media.download() def test_matplotlib(): - if sys.version_info < (3,4): + #for now, python 3.5 installs a version of matplotlib that complains + #about $DISPLAY variable, so lets just ignore for now. + if sys.version_info < (3,4) or sys.version_info == (3,5): return import matplotlib.pyplot as plt From 5dc17a3becba91555a565535ac9ac2837ca0e521 Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 11:08:20 -0500 Subject: [PATCH 07/10] fix version --- tests/test_examples.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 9cb1fb9db..92d3b2418 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -13,7 +13,10 @@ def test_download_media(capsys): def test_matplotlib(): #for now, python 3.5 installs a version of matplotlib that complains #about $DISPLAY variable, so lets just ignore for now. - if sys.version_info < (3,4) or sys.version_info == (3,5): + if sys.version_info < (3,4): + return + + if sys.version_info.major == 3 and sys.version_info.minor == 5: return import matplotlib.pyplot as plt From d5324c22702b5ebce9cda3b50acd53eaa8f35afe Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 11:17:27 -0500 Subject: [PATCH 08/10] back out duration change --- moviepy/video/compositing/concatenate.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/moviepy/video/compositing/concatenate.py b/moviepy/video/compositing/concatenate.py index bec799111..67bd689c2 100644 --- a/moviepy/video/compositing/concatenate.py +++ b/moviepy/video/compositing/concatenate.py @@ -82,15 +82,12 @@ def make_frame(t): i = max([i for i, e in enumerate(tt) if e <= t]) return clips[i].get_frame(t - tt[i]) - def get_mask(c): - mask = c.mask or ColorClip([1, 1], col=1, ismask=True) - if mask.duration is None: - mask.duration = c.duration - return mask - result = VideoClip(ismask = ismask, make_frame = make_frame) if any([c.mask is not None for c in clips]): - masks = [get_mask(c) for c in clips] + masks = [c.mask.set_duration(c.duration) if (c.mask is not None) else + ColorClip([1,1], col=1, ismask=True, duration=c.duration) + #ColorClip(c.size, col=1, ismask=True).set_duration(c.duration) + for c in clips] result.mask = concatenate_videoclips(masks, method="chain", ismask=True) result.clips = clips elif method == "compose": From a7e01c367790f451e6ae509279a98cb3eedf529c Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 11:20:20 -0500 Subject: [PATCH 09/10] put changes back in --- moviepy/video/compositing/concatenate.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/moviepy/video/compositing/concatenate.py b/moviepy/video/compositing/concatenate.py index 67bd689c2..6923567cc 100644 --- a/moviepy/video/compositing/concatenate.py +++ b/moviepy/video/compositing/concatenate.py @@ -82,12 +82,15 @@ def make_frame(t): i = max([i for i, e in enumerate(tt) if e <= t]) return clips[i].get_frame(t - tt[i]) + def get_mask(c): + mask = c.mask or ColorClip([1, 1], col=1, ismask=True) + if mask.duration is None: + mask.duration = c.duration + return mask + result = VideoClip(ismask = ismask, make_frame = make_frame) if any([c.mask is not None for c in clips]): - masks = [c.mask.set_duration(c.duration) if (c.mask is not None) else - ColorClip([1,1], col=1, ismask=True, duration=c.duration) - #ColorClip(c.size, col=1, ismask=True).set_duration(c.duration) - for c in clips] + masks = [get_mask(c) for c in clips] result.mask = concatenate_videoclips(masks, method="chain", ismask=True) result.clips = clips elif method == "compose": From 6d44a7567ccc52cb0c9aefce8ddae30006cdd891 Mon Sep 17 00:00:00 2001 From: Billy Earney Date: Mon, 13 Mar 2017 11:30:50 -0500 Subject: [PATCH 10/10] remove :0 from .travis file --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c2347ebbb..efeaef852 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,12 @@ before_install: - sudo apt-get install -y ffmpeg - mkdir media install: - - if [[ $TRAVIS_PYTHON_VERSION == '3.4' || $TRAVIS_PYTHON_VERSION == '3.5' || $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install matplotlib==2.0.0; pip install -U scikit-learn; pip install scipy; fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.4' || $TRAVIS_PYTHON_VERSION == '3.5' || $TRAVIS_PYTHON_VERSION == '3.6' ]]; then pip install matplotlib; pip install -U scikit-learn; pip install scipy; fi - pip install coveralls - pip install pytest-cov - python setup.py install # command to run tests before_script: - - echo $DISPLAY - py.test tests/ --cov script: py.test tests/ --doctest-modules -v --cov moviepy --cov-report term-missing after_success: