mcap_protobuf.writer module

class mcap_protobuf.writer.Writer(output: str | IO[Any] | BufferedWriter, chunk_size: int = 1048576, compression: CompressionType = CompressionType.ZSTD, enable_crcs: bool = True)[source]

Bases: object

Writer provides a higher-level abstraction for writing Protobuf messages to an MCAP file.

finish()[source]

Writes the index and footer to the MCAP file.

write_message(topic: str, message: Any, log_time: int | None = None, publish_time: int | None = None, sequence: int = 0)[source]

Writes a message to an MCAP file.

Parameters:
  • topic – the topic that this message was originally published on.

  • message – a Protobuf object to write into the MCAP.

  • log_time – unix nanosecond timestamp of when this message was written to the MCAP.

  • publish_time – unix nanosecond timestamp of when this message was originally published.

  • sequence – an optional sequence count for messages on this topic.