class VideoFileStreamWriter(StreamWriter): def __init__(self, file_name, frame_rate): self._file_name = file_name self._frame_rate = frame_rate self._video_writer = None def __del(self): self.close() def _open(self, frame_size): self._video_writer = VideoWriter(self._file_name, frame_size, self._frame_rate) def write(self, image): if self._video_writer is None: self._open(image.size) self._video_writer.write_frame(image) def close(self): if self._video_writer is not None: self._video_writer.close()
def _open(self, frame_size): self._video_writer = VideoWriter(self._file_name, frame_size, self._frame_rate)