def main(self, filename): self.config = _config audio_producer = mod.Decoder(self.config.audio, filename) header_view = ModHeaderView(audio_producer) pattern_view = ModPatternView(audio_producer) root_view = Framer() root_view.add(header_view, makerect(0, 0, self.config.video.width, self.config.video.height / 30)) root_view.add(pattern_view, makerect(0, self.config.video.height / 30, self.config.video.width, self.config.video.height - (self.config.video.height / 30))) video_producer = SurfaceHandler(self.config.video, root_view) state = {'video': {'frames_produced': 0}, 'audio': {'frames_produced': 0}, 'frame': 0, 'elapsed_sec': 0.0} preview = Preview(self.config.video) def get_frames(): # TODO: Move this function into a sequencer video = video_producer.render(state) preview.update_image(video) audio_frames_required = self._audio_frames_to_next_video_frame(state) audio = audio_producer.render(audio_frames_required) state['video']['frames_produced'] += 1 state['audio']['frames_produced'] += audio_frames_required state['frame'] += 1 state['elapsed_sec'] = state['frame'] / self.config.video.fps if video is None or audio is None or preview.is_stop_requested(): return None else: return video, audio preview.show_preview_ui() try: ffmpegger = VideoRunner(self.config) ffmpegger.start(get_frames) finally: preview.destroy_preview_ui()