Video editing with Python
Fixed critical bugs in audio (32bit bug + artifacts). changed ffmpeg loglevels
Zulkoa1389b5d1ee7
diff --git a/moviepy/audio/AudioClip.py b/moviepy/audio/AudioClip.pyindex 7796be11..3afe0565 100644--- a/moviepy/audio/AudioClip.py+++ b/moviepy/audio/AudioClip.py@@ -77,11 +77,13 @@ class AudioClip(Clip):"""if tt is None:tt = np.arange(0,self.duration, 1.0/fps)++ #print tt.max() - tt.min(), tt.min(), tt.max()snd_array = self.get_frame(tt)snd_array = np.maximum(-0.99,np.minimum(0.99,snd_array))- inttype = {1:'int8',2:'int16',4:'int32'}[nbytes]+ inttype = {1:'int8',2:'int16', 4:'int32'}[nbytes]return (2**(8*nbytes-1)*snd_array).astype(inttype)diff --git a/moviepy/audio/io/ffmpeg_audiowriter.py b/moviepy/audio/io/ffmpeg_audiowriter.pyindex 2de9f107..caf778ae 100644--- a/moviepy/audio/io/ffmpeg_audiowriter.py+++ b/moviepy/audio/io/ffmpeg_audiowriter.py@@ -94,9 +94,10 @@ def ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize,nchunks = totalsize // buffersize + 1pospos = list(range(0, totalsize, buffersize))+[totalsize]+for i in tqdm(range(nchunks)):tt = (1.0/fps)*np.arange(pospos[i],pospos[i+1])- sndarray = clip.to_soundarray(tt,nbytes)+ sndarray = clip.to_soundarray(tt, nbytes= nbytes)writer.write_frames(sndarray)writer.close()diff --git a/moviepy/audio/io/readers.py b/moviepy/audio/io/readers.pyindex e075f668..08ad2392 100644--- a/moviepy/audio/io/readers.py+++ b/moviepy/audio/io/readers.py@@ -140,8 +140,10 @@ class FFMPEG_AudioReader:"""if (pos < self.pos) or (pos> (self.pos+1000000)):t = 1.0*pos/self.fps- self.initialize(t)++ self.initialize(t)elif pos > self.pos:+ #print posself.skip_chunk(pos-self.pos)# last case standing: pos = current posself.pos = pos@@ -165,7 +167,9 @@ class FFMPEG_AudioReader:# elements of t that are actually in timein_time = (tt>=0) & (tt < self.duration)- frames = (self.fps*tt+1).astype(int)[in_time]+ # The np.round in the next line is super-important.+ # Removing it results in artifacts in the noise.+ frames = np.round((self.fps*tt+1)).astype(int)[in_time]fr_min, fr_max = frames.min(), frames.max()if not (0 <=@@ -205,7 +209,7 @@ class FFMPEG_AudioReader:Fills the buffer with frames, centered on ``framenumber``if possible"""-+# start-frame for the buffernew_bufferstart = max(0, framenumber - self.buffersize // 2)diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex 9f3e5edd..a8e90986 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -118,7 +118,7 @@ class VideoClip(Clip):def to_videofile(self, filename, fps=24, codec='libx264',bitrate=None, audio=True, audio_fps=44100,- audio_nbytes = 2, audio_codec= 'libvorbis',+ audio_nbytes = 4, audio_codec= 'libvorbis',audio_bitrate = None, audio_bufsize = 2000,temp_audiofile=None,rewrite_audio = True, remove_temp = True,diff --git a/moviepy/video/io/ffmpeg_writer.py b/moviepy/video/io/ffmpeg_writer.pyindex 997c2877..619b6d27 100644--- a/moviepy/video/io/ffmpeg_writer.py+++ b/moviepy/video/io/ffmpeg_writer.py@@ -76,6 +76,7 @@ class FFMPEG_VideoWriter:self.filename = filenamecmd = ([ FFMPEG_BINARY, '-y',+ "-loglevel", "panic" if logfile==DEVNULL else "info","-f", 'rawvideo',"-vcodec","rawvideo",'-s', "%dx%d"%(size[0],size[1]),