Video editing with Python
said to update ffmpeg for Ubuntu/Debian users in README
Zulkob78f35ef325e
diff --git a/README.rst b/README.rstindex 571462cd..2cc8780e 100644--- a/README.rst+++ b/README.rst@@ -39,7 +39,10 @@ MoviePy cannot run without these dependencies:- `Numpy`_ is needed for image and sound manipulation.- The Decorator_ module is used in the MoviePy code for better code readability.-**Make sure to use a recent version of ffmpeg**. You can either install it or save the binary files in any folder and specify the path to these folders before installing MoviePy (for the latter, see `Manual installation`_ below).+**Make sure to use a recent version of ffmpeg**.+You can either install it or save the binary files in any folder and specify the path to these folders before installing MoviePy (for the latter, see `Manual installation`_ below).++*Debian and Ubuntu users*, you certainly have an out-of-date version of ffmpeg, you *must* download a recent version from the ffmpeg_ website.Normally Numpy and Decorator will be automatically installed when you install MoviePy. In case of doubt/problem they can also be installed manually.Numpy can be installed with most software managers on Linux distributions. Both Numpy and Decorator can be installed as follows with pip: ::diff --git a/moviepy/video/compositing/transitions.py b/moviepy/video/compositing/transitions.pyindex e9e0158c..d81a572f 100644--- a/moviepy/video/compositing/transitions.py+++ b/moviepy/video/compositing/transitions.py@@ -5,7 +5,9 @@ if you load them with ``from moviepy.all import *``"""from moviepy.decorators import requires_duration, add_mask_if_none-from moviepy.video.fx import fadein, fadeout+from .CompositeVideoClip import CompositeVideoClip+from moviepy.video.fx.fadein import fadein+from moviepy.video.fx.fadeout import fadeout@add_mask_if_nonedef crossfadein(clip, duration):@@ -28,3 +30,23 @@ def crossfadeout(clip, duration):newclip = clip.copy()newclip.mask = clip.mask.fx(fadeout, duration)return newclip+++++++++++@requires_duration+def make_loopable(clip, cross_duration):+ """ 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(crossfadein, cross_duration).\+ set_start(d - cross_duration)+ return CompositeVideoClip([ clip, clip2 ]).\+ subclip(cross_duration,d)diff --git a/moviepy/video/io/preview.py b/moviepy/video/io/preview.pyindex 1610f8d3..4cc23b41 100644--- a/moviepy/video/io/preview.py+++ b/moviepy/video/io/preview.py@@ -32,7 +32,7 @@ def show(clip, t=0, with_mask=True):clip = clip.to_RGB()if with_mask and (clip.mask != None):import moviepy.video.compositing.CompositeVideoClip as cvc- clip = cvc.CompositeVideoClip([clip])+ clip = cvc.CompositeVideoClip([clip.set_pos((0,0))])imdisplay(clip.get_frame(t))@@ -85,25 +85,50 @@ def preview(clip, fps=15, audio=True, audio_fps=22050,if audio: # synchronize with audiovideoFlag.set() # say to the audio: video is readyaudioFlag.wait() # wait for the audio to be ready-++ result = []+t0 = time.time()for t in np.arange(1.0 / fps, clip.duration, 1.0 / fps):img = clip.get_frame(t)for event in pg.event.get():- if event.type == pg.KEYDOWN:- if (event.key == pg.K_ESCAPE):- videoFlag.clear()- print "Keyboard interrupt"- return-- elif event.type == pg.MOUSEBUTTONDOWN:- x,y = pg.mouse.get_pos()- rgb = img[y,x]- print "time, position, color : ", "%.03f, %s, %s"%(- t,str((x,y)),str(rgb))+ if event.type == pg.KEYDOWN:+ if (event.key == pg.K_ESCAPE):+ videoFlag.clear()+ print "Keyboard interrupt"+ return result++ elif event.type == pg.MOUSEBUTTONDOWN:+ x,y = pg.mouse.get_pos()+ rgb = img[y,x]+ result.append({'time':t, 'position':(x,y),+ 'color':rgb})+ print "time, position, color : ", "%.03f, %s, %s"%(+ t,str((x,y)),str(rgb))t1 = time.time()time.sleep(max(0, t - (t1-t0)) )imdisplay(img, screen)++def image_preview(clip):++ clip.show()+ result=[]+ while True:+ for event in pg.event.get():+ if event.type == pg.KEYDOWN:+ if (event.key == pg.K_ESCAPE):+ videoFlag.clear()+ print "Keyboard interrupt"+ return result+ elif event.type == pg.MOUSEBUTTONDOWN:+ x,y = pg.mouse.get_pos()+ rgb = img[y,x]+ result.append({'time':t, 'position':(x,y),+ 'color':rgb})+ print "time, position, color : ", "%.03f, %s, %s"%(+ t,str((x,y)),str(rgb))+ return result+