def assemble(self, end_timestamp_ms): if lib.WebPAnimEncoderAdd(self.ptr, ffi.NULL, end_timestamp_ms, ffi.NULL) == 0: raise WebPError('encoding error: ' + self.ptr.error_code) _webp_data = _WebPData() if lib.WebPAnimEncoderAssemble(self.ptr, _webp_data.ptr) == 0: raise WebPError('error assembling animation') return _webp_data.done()
def encode_frame(self, frame, timestamp_ms, config=None): """Add a frame to the animation. Args: frame (WebPPicture): Frame image. timestamp_ms (int): When the frame should be shown (in milliseconds). config (WebPConfig): Encoder configuration. """ if config is None: config = WebPConfig.new() if lib.WebPAnimEncoderAdd(self.ptr, frame.ptr, timestamp_ms, config.ptr) == 0: raise WebPError('encoding error: ' + self.ptr.error_code)