Skip to content

Video editing with Python

modified headblur to avoid crash when cv2 is missing

Zulko920c92ba21e1
diff --git a/moviepy/all.py b/moviepy/all.py
index 1d0354d3..12123f8f 100644
--- a/moviepy/all.py
+++ b/moviepy/all.py
@@ -9,7 +9,7 @@ by simply typing: from moviepy.all import *
# Clips
from moviepy.video.io.VideoFileClip import VideoFileClip
-from moviepy.video.VideoClip import ImageClip, ColorClip, TextClip
+from moviepy.video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip
from moviepy.video.compositing.concatenate import concatenate
from moviepy.audio.io.AudioFileClip import AudioFileClip
diff --git a/moviepy/video/fx/headblur.py b/moviepy/video/fx/headblur.py
index c4eda360..45a42303 100644
--- a/moviepy/video/fx/headblur.py
+++ b/moviepy/video/fx/headblur.py
@@ -1,6 +1,15 @@
-import cv2
import numpy as np
+
+#------- CHECKING DEPENDENCIES -----------------------------------------
+try:
+ import cv2
+ headblur_possible = True
+except:
+ headblur_possible = False
+#-----------------------------------------------------------------------
+
+
def headblur(clip,fx,fy,r_zone,r_blur=None):
"""
Returns a filter that will blurr a moving part (a head ?) of
@@ -35,3 +44,14 @@ def headblur(clip,fx,fy,r_zone,r_blur=None):
return im
return clip.fl(fl)
+
+
+
+#------- OVERWRITE IF REQUIREMENTS NOT MET -----------------------------
+if not headblur_possible:
+ doc = headblur.__doc__
+ def headblur(clip,fx,fy,r_zone,r_blur=None):
+ raise IOError("fx painting needs scikit-image or scipy")
+
+ headblur.__doc__ = doc
+#-----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index 33611351..07dac0f7 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ ez_setup.use_setuptools()
from setuptools import setup, find_packages
setup(name='moviepy',
- version='0.2.1.6',
+ version='0.2.1.6.1',
author='Zulko 2013',
description='Module for script-based video editing',
long_description=open('README.rst').read(),