# HG changeset patch # User drewp@bigasterisk.com # Date 2019-06-04 17:19:12 # Node ID 748ecc2d1f2a7a01dbc96200a272ee9ec3e60eaa # Parent 82e98aa4d159e82a796a70f9e03fd83450acdb8a vidref fix state machine for writing files Ignore-this: 7f14601f09e4993c99d04a92361a84a6 diff --git a/light9/vidref/videorecorder.py b/light9/vidref/videorecorder.py --- a/light9/vidref/videorecorder.py +++ b/light9/vidref/videorecorder.py @@ -90,12 +90,15 @@ class FramesToVideoFiles: return threads.deferToThread(self._bg_save, outBase) def _bg_save(self, outBase): + os.makedirs(os.path.dirname(outBase), exist_ok=True) self.frameMap = open(outBase + '.timing', 'wt') # (immediately calls make_frame) - self.currentOutputClip = moviepy.editor.VideoClip( - self._bg_make_frame, duration=999.) - self.currentOutputClip.fps = 5 + self.currentOutputClip = moviepy.editor.VideoClip(self._bg_make_frame, + duration=999.) + # The fps recorded in the file doesn't matter much; we'll play + # it back in sync with the music regardless. + self.currentOutputClip.fps = 10 log.info(f'write_videofile {outBase} start') try: self.currentOutputClip.write_videofile(outBase + '.mp4', @@ -111,9 +114,15 @@ class FramesToVideoFiles: def _bg_make_frame(self, video_time_secs): if self.nextWriteAction == 'close': - raise StopIteration # the one in write_videofile + raise StopIteration # the one in write_videofile + elif self.nextWriteAction == 'notWritingClip': + raise NotImplementedError + elif self.nextWriteAction == 'saveFrames': + pass + else: + raise NotImplementedError(self.nextWriteAction) - # should be a queue to miss fewer frames + # should be a little queue to miss fewer frames while self.nextImg is None: time.sleep(.03) cf, self.nextImg = self.nextImg, None