Skip to content

Video editing with Python

Staged a few effect files (lum_contrast, gamma_corr, time_symetrize, etc.)

Zulkodeb8a689a428
diff --git a/docs/_static/logo_small.jpeg b/docs/_static/logo_small.jpeg
new file mode 100644
index 00000000..da83da04
Binary files /dev/null and b/docs/_static/logo_small.jpeg differ
diff --git a/moviepy/video/fx/gamma_corr.py b/moviepy/video/fx/gamma_corr.py
new file mode 100644
index 00000000..5668698a
--- /dev/null
+++ b/moviepy/video/fx/gamma_corr.py
@@ -0,0 +1,8 @@
+
+def gamma_corr(clip, gamma):
+ """ Gamma-correction of a video clip """
+ def fl(im):
+ corrected = (255*(1.0*im/255)**gamma)
+ return corrected.astype('uint8')
+
+ return clip.fl_image(fl)
diff --git a/moviepy/video/fx/lum_contrast.py b/moviepy/video/fx/lum_contrast.py
new file mode 100644
index 00000000..992b420e
--- /dev/null
+++ b/moviepy/video/fx/lum_contrast.py
@@ -0,0 +1,11 @@
+def lum_contrast(clip, lum = 0, contrast=0, contrast_thr=127):
+ """ luminosity-contrast correction of a clip """
+
+ def fl_image(im):
+ im = 1.0*im # float conversion
+ corrected = im + lum + factor*(im-thr)
+ corrected[corrected < 0] = 0
+ corrected[corrected > 255] = 255
+ return corrected.astype('uint8')
+
+ return clip.fl_image(fl_image)
diff --git a/moviepy/video/fx/make_loopable.py b/moviepy/video/fx/make_loopable.py
new file mode 100644
index 00000000..a7162ba4
--- /dev/null
+++ b/moviepy/video/fx/make_loopable.py
@@ -0,0 +1,12 @@
+import moviepy.video.compositing.transitions as transfx
+
+def make_loopable(clip, cross):
+ """
+ Makes the clip fade in progressively at its own end, this way
+ it can be looped indefinitely. ``cross`` is the duration in seconds
+ of the fade-in. """
+ d = clip.duration
+ clip2 = clip.fx(transfx.crossfadein, cross).\
+ set_start(d - cross)
+ return CompositeVideoClip([ clip, clip2 ]).\
+ subclip(cross,d)
diff --git a/moviepy/video/fx/time_symetrize.py b/moviepy/video/fx/time_symetrize.py
new file mode 100644
index 00000000..e81add43
--- /dev/null
+++ b/moviepy/video/fx/time_symetrize.py
@@ -0,0 +1,16 @@
+from moviepy.decorators import (apply_to_mask, apply_to_audio,
+ requires_duration)
+from moviepy.video.compositing.concatenate import concatenate
+from .time_mirror import time_mirror
+
+@requires_duration
+@apply_to_mask
+def time_symetrize(clip):
+ """
+ Returns a clip that plays the current clip once forwards and
+ then once backwards. This is very practival to make video that
+ loop well, e.g. to create animated GIFs.
+ This effect is automatically applied to the clip's mask and audio
+ if they exist.
+ """
+ return concatenate([clip, clip.fx( time_mirror )])