Video editing with Python
corrected audio preview, fixed a few things in docs
Zulko1d2ef9e02c7d
diff --git a/docs/examples/examples.rst b/docs/examples/examples.rstindex 7539ce03..e78b0275 100644--- a/docs/examples/examples.rst+++ b/docs/examples/examples.rst@@ -3,8 +3,7 @@Example Scripts===============-Here are a few example scripts to get you started, including, as promised,-the scripts used for the clips of the demonstration video.+Here are a few example scripts to get you started. There are quite old now and will be soon replaced... toctree::@@ -17,7 +16,6 @@ the scripts used for the clips of the demonstration video.masked_creditspainting_effectcompo_from_image- headblurthe_enddiff --git a/docs/getting_started/getting_started.rst b/docs/getting_started/getting_started.rstindex 7038a457..9904b9fe 100644--- a/docs/getting_started/getting_started.rst+++ b/docs/getting_started/getting_started.rst@@ -1,6 +1,6 @@.. _getting_started:-These pages give you everything you need to start editing with MoviePy. Then the best way to learn is to have a look at the provided :ref:`examples` or the different ressources presented in the :ref:`gallery`.+These pages explain everything you need to start editing with MoviePy. To go further, have a look at the :ref:`gallery` and the :ref:`examples`.Getting started with MoviePydiff --git a/docs/getting_started/quick_presentation.rst b/docs/getting_started/quick_presentation.rstindex a5b6245f..a280bb3c 100644--- a/docs/getting_started/quick_presentation.rst+++ b/docs/getting_started/quick_presentation.rst@@ -8,13 +8,13 @@ This section explains when MoviePy can be used and how it works.Do I need MoviePy ?~~~~~~~~~~~~~~~~~~~-There are already many good free video editing softwares out there with nice graphical interfaces (my favorites being OpenShot and KDEnlive). So why write videos using scripts ? Here are a few reasons:+Here are a few reasons why you may want to edit videos in Python:- You have many videos to process or to compose in a complicated way.- You want to automatize the creation of videos or GIFs on a web server (Django, Flask, etc.)- You want to automatize tedious tasks, like title insertions tracking objects, cuting scenes, making end credits, subtitles, etc...- You want to code your own video effects to do something no existing video editor can.-- You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh...)+- You want to create animations from images generated by another python library (Matplotlib, Mayavi, Gizeh, scikit-images...)Advantages and limitations~~~~~~~~~~~~~~~~~~~~~~~~~~~diff --git a/moviepy/audio/io/preview.py b/moviepy/audio/io/preview.pyindex a715fb1c..cc539d4a 100644--- a/moviepy/audio/io/preview.py+++ b/moviepy/audio/io/preview.py@@ -46,7 +46,7 @@ def preview(clip, fps=22050, buffersize=4000, nbytes= 2,totalsize = int(fps*clip.duration)pospos = np.array(list(range(0, totalsize, buffersize))+[totalsize])tt = (1.0/fps)*np.arange(pospos[0],pospos[1])- sndarray = clip.to_soundarray(tt,nbytes)+ sndarray = clip.to_soundarray(tt,nbytes=nbytes, quantize=True)chunk = pg.sndarray.make_sound(sndarray)if (audioFlag !=None) and (videoFlag!= None):@@ -56,7 +56,7 @@ def preview(clip, fps=22050, buffersize=4000, nbytes= 2,channel = chunk.play()for i in range(1,len(pospos)-1):tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])- sndarray = clip.to_soundarray(tt,nbytes)+ sndarray = clip.to_soundarray(tt,nbytes=nbytes, quantize=True)chunk = pg.sndarray.make_sound(sndarray)while channel.get_queue():time.sleep(0.003)diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex a0853994..b5e5c040 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -1110,3 +1110,9 @@ class TextClip(ImageClip):return [l[8:] for l in lines if l.startswith(" Font:")]elif arg == 'color':return [l.split(" ")[1] for l in lines[2:]]++ @staticmethod+ def search(string, arg):+ string = string.lower()+ names_list = TextClip.list(arg)+ return [name for name in names_list if string in name.lower()]diff --git a/moviepy/video/tools/subtitles.py b/moviepy/video/tools/subtitles.pyindex 33c0d357..ad7c035c 100644--- a/moviepy/video/tools/subtitles.py+++ b/moviepy/video/tools/subtitles.py@@ -68,18 +68,18 @@ class SubtitlesClip(VideoClip):self.textclips[sub] = self.make_textclip(sub[1])return sub- def get_frame(t):+ def make_frame(t):sub = add_textclip_if_none(t)return (self.textclips[sub].get_frame(t) if subelse np.array([[[0,0,0]]]))- def mask_get_frame(t):+ def make_mask_frame(t):sub = add_textclip_if_none(t)return (self.textclips[sub].mask.get_frame(t) if subelse np.array([[0]]))- self.get_frame = get_frame- self.mask = VideoClip(ismask=True, get_frame=mask_get_frame)+ self.make_frame = make_frame+ self.mask = VideoClip(make_mask_frame, ismask=True)@@ -114,6 +114,7 @@ class SubtitlesClip(VideoClip):with open(filename, 'w+') as f:f.write(str(self))+def file_to_subtitles(filename):""" Converts a srt file into subtitles.