Video editing with Python
moved pygame import in editor, added audioCompositeClip in editor, added stdin.close in ffmpeg_writer
Zulko65baec704d0d
diff --git a/moviepy/audio/AudioClip.py b/moviepy/audio/AudioClip.pyindex 90ffa7d8..7796be11 100644--- a/moviepy/audio/AudioClip.py+++ b/moviepy/audio/AudioClip.py@@ -101,14 +101,6 @@ class AudioClip(Clip):return ffmpeg_audiowrite(self,filename, fps, nbytes, buffersize,codec, bitrate, verbose)-try:- # Add method preview (only if pygame installed)- from moviepy.audio.io.preview import preview- AudioClip.preview = preview--except:- pass-class AudioArrayClip(AudioClip):"""diff --git a/moviepy/editor.py b/moviepy/editor.pyindex 732ce488..a874eae5 100644--- a/moviepy/editor.py+++ b/moviepy/editor.py@@ -9,6 +9,9 @@ folders and turn them into VideoClip methods, so that instead of>>> clip.fx( vfx.resize, 2 ) # or equivalently vfx.resize(clip, 2)we can write>>> clip.resize(2)++It also starts a PyGame session (if PyGame is installed) and enables+clip.preview()."""# Note that these imports could have been performed in the __init__.py@@ -21,7 +24,7 @@ from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClipfrom .video.compositing.CompositeVideoClip import CompositeVideoClipfrom .video.compositing.concatenate import concatenate-from .audio.AudioClip import AudioClip+from .audio.AudioClip import AudioClip, CompositeAudioClipfrom .audio.io.AudioFileClip import AudioFileClip# FX@@ -62,3 +65,34 @@ for method in ["afx.audio_fadein","afx.audio_fadeout"]:exec("AudioClip.%s = %s"%( method.split('.')[1], method))++#-----------------------------------------------------------------+# Previews: try to import pygame+++# Add methods preview and show (only if pygame installed)+try:+ from moviepy.video.io.preview import show, preview+except ImportError:+ def preview(self, *args, **kwargs):+ """ NOT AVAILABLE : clip.preview requires Pygame installed """+ raise ImportError("clip.preview requires Pygame installed")+ def show(self, *args, **kwargs):+ """ NOT AVAILABLE : clip.show requires Pygame installed """+ raise ImportError("clip.show requires Pygame installed")+++VideoClip.preview = preview+VideoClip.show = show++try:+ from moviepy.audio.io.preview import preview+except ImportError:+ def preview(self, *args, **kwargs):+ """ NOT AVAILABLE : clip.preview requires Pygame installed """+ raise ImportError("clip.preview requires Pygame installed")++AudioClip.preview = preview+++diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 363fd4f1..25942ab8 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -675,25 +675,6 @@ class VideoClip(Clip):"""self.audio = self.audio.fx(fun, *a, **k)-- #------------------------------------------------------------------ # Previews:----# Add methods preview and show (only if pygame installed)-try:- from moviepy.video.io.preview import show, preview-except ImportError:- def preview(self, *args, **kwargs):- """ NOT AVAILABLE : clip.preview requires Pygame installed """- raise ImportError("clip.preview requires Pygame installed")- def show(self, *args, **kwargs):- """ NOT AVAILABLE : clip.show requires Pygame installed """- raise ImportError("clip.show requires Pygame installed")--VideoClip.preview = preview-VideoClip.show = showdiff --git a/moviepy/video/io/ffmpeg_reader.py b/moviepy/video/io/ffmpeg_reader.pyindex 0e4d264e..808a82e2 100644--- a/moviepy/video/io/ffmpeg_reader.py+++ b/moviepy/video/io/ffmpeg_reader.py@@ -117,7 +117,7 @@ class FFMPEG_VideoReader:assert len(s) == nbytesresult = np.fromstring(s,dtype='uint8').reshape((h, w, len(s)//(w*h)))- self.proc.stdout.flush()+ #self.proc.stdout.flush()except IOError:diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex cf3a2f7f..d6879645 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -73,6 +73,7 @@ class FFMPEG_VideoWriter:def write_frame(self,img_array):""" Writes 1 frame in the file ! """self.proc.stdin.write(img_array.tostring())+ #self.proc.stdin.flush()def close(self):self.proc.stdin.close()