Video editing with Python
Various bug fixes in writing (python3 compat, chunk division...)
Zulko61cc5ac2de99
diff --git a/README.rst b/README.rstindex 769cab4a..311e49e4 100644--- a/README.rst+++ b/README.rst@@ -31,13 +31,12 @@ Download and Installation---------------------------MoviePy requires the Python modules Numpy_, Decorator_, and tqdm_. All of these will all be automatically installed during MoviePy's installation.+You will also need a **recent version** of the software ffmpeg_ , preferably downloaded directly from the ffmpeg website.-If you intend to use advanced features you will also need a few other dependencies like ImageMagick_ , Pygame_ etc. (see `the docs <http://zulko.github.io/moviepy/install.html>`_).-Installation---------------+If you intend to use advanced features you must install a few other dependencies like ImageMagick_ , Pygame_ etc. (see `the docs <http://zulko.github.io/moviepy/install.html>`_).-First method : if you have ``pip`` installed, just type this in a terminal (sudo is optional on some systems) ::+First installation method : if you have ``pip`` installed, just type this in a terminal (sudo is optional on some systems) ::(sudo) pip install moviepydiff --git a/moviepy/audio/io/ffmpeg_audiowriter.py b/moviepy/audio/io/ffmpeg_audiowriter.pyindex 3c8b6301..66e2fc45 100644--- a/moviepy/audio/io/ffmpeg_audiowriter.py+++ b/moviepy/audio/io/ffmpeg_audiowriter.py@@ -8,6 +8,7 @@ from tqdm import tqdmfrom moviepy.conf import FFMPEG_BINARYfrom moviepy.decorators import requires_duration+from moviepy.tools import sys_write_flushclass FFMPEG_AudioWriter:"""@@ -52,15 +53,16 @@ class FFMPEG_AudioWriter:+ ['-acodec', codec]+ (['-b',bitrate] if (bitrate!=None) else [])+ [ filename ])- self.proc = sp.Popen(cmd,stdin=sp.PIPE,- stderr=sp.PIPE)++ self.proc = sp.Popen(cmd,stdin=sp.PIPE, stderr=sp.PIPE)def write_frames(self,frames_array):self.proc.stdin.write(frames_array.tostring())+def close(self):self.proc.stdin.close()- self.proc.stderr.close()+ self.proc.wait()del self.proc@@ -73,12 +75,8 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,to a file."""- if verbose:- def verbose_print(s):- sys.stdout.write(s)- sys.stdout.flush()- else:- verbose_print = lambda *a : None+ def verbose_print(s):+ if verbose: sys_write_flush(s)verbose_print("Writing audio in %s\n"%filename)@@ -86,13 +84,18 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,codec=codec, bitrate=bitrate)totalsize = int(fps*clip.duration)- nchunks = totalsize // buffersize + 1- pospos = np.array(list(range(0, totalsize, buffersize))+[totalsize])- for i in tqdm(range(nchunks)):+ if (totalsize % buffersize == 0):+ nchunks = totalsize // buffersize+ else:+ nchunks = totalsize // buffersize + 1++ pospos = list(range(0, totalsize, buffersize))+[totalsize]+ for i in range(nchunks):tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])sndarray = clip.to_soundarray(tt,nbytes)writer.write_frames(sndarray)writer.close()+verbose_print("Done writing Audio in %s !\n"%filename)diff --git a/moviepy/tools.py b/moviepy/tools.pyindex 4104ddc8..32795e44 100644--- a/moviepy/tools.py+++ b/moviepy/tools.py@@ -23,12 +23,14 @@ def subprocess_call(cmd, stdout=None, stdin = None,proc = sp.Popen(cmd, stdout=stdout,stdin = stdin,- stderr = stderr)+ stderr = stderr )proc.wait()if proc.returncode and errorprint:- sys_write_flush( "\nWARNING: this command returned an error:")+ sys_write_flush( "\nMoviePy: WARNING !\n"+ " The following command returned an error:\n")sys_write_flush( proc.stderr.read().decode('utf8'))+ raise IOErrorelse:verboseprint( "\n... command successful.\n")diff --git a/moviepy/version.py b/moviepy/version.pyindex 5d053a1d..0370c18e 100644--- a/moviepy/version.py+++ b/moviepy/version.py@@ -1 +1 @@-__version__ = '0.2.1.7.06'+__version__ = '0.2.1.7.07'diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 6b39269d..e97cedda 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -322,6 +322,7 @@ class VideoClip(Clip):filename, ffmpeg_output=True)if remove_temp:+ print("print")os.remove(videofile)if not isinstance(audio,str):os.remove(temp_audiofile)diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex f59458db..d9b89607 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -54,11 +54,11 @@ class FFMPEG_VideoWriter:['-b',bitrate] if (bitrate!=None) else []) + ['-r', "%d"%fps,filename ]+self.proc = sp.Popen(cmd,stdin=sp.PIPE, stderr=sp.PIPE)def write_frame(self,img_array):self.proc.stdin.write(img_array.tostring())- #img_array.tofile(self.proc.stdin) only python 2.7def close(self):self.proc.stdin.close()