def build_movie(self): """ Concatenate self._full_frames images into video file, add back original music. """ from moviepy.editor import AudioFileClip, ImageSequenceClip outname = self.decomposer.wav_file.replace('input', 'output') outname = outname.replace('wav', 'mp4') output = ImageSequenceClip( [self._generate_keyboard(t)[0] for t in range(self.decomposer.chromagram_raw.shape[1])], fps=self.fps_out/2 ) output = output.cutout(0, 1) # trim to compensate for FFT lag output = output.set_audio(AudioFileClip(self.decomposer.wav_file)) output.write_videofile( outname, fps=self.fps_out, temp_audiofile="temp-audio.m4a", remove_temp=True, codec="libx264", audio_codec="aac" )