Skip to content

refactor(mcap): encode and rewrite video messages through hebbian-mcap 0.1.1 - #785

Merged
kstonekuan merged 1 commit into
mainfrom
use-native-mcap-encoders
Nov 15, 2026
Merged

kstonekuan merged 1 commit into
mainfrom
use-native-mcap-encoders

Conversation

@kstonekuan

@kstonekuan kstonekuan commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Outcome

HFlow no longer carries its own code for building and re-serializing CompressedVideo messages. That logic now lives in the shared Rust core of hebbian-mcap 0.1.1, used through its Python bindings.

  • Encoding: the video importer, the LeRobot importer and the transform build video messages and the schema record with encode_compressed_video and COMPRESSED_VIDEO_SCHEMA.
  • Pass-through video: transform and doctor read messages through CompressedVideoCodec. ROS 2 CDR messages are walked by the channel's own schema, so fields a recorder added are still preserved when an access unit delimiter is inserted. Protobuf payloads are replaced at the wire level, so unknown fields survive.
  • Removed: _resolve_encoder, _Ros2VideoMessageWithData and doctor's decoder-factory loop.

Decoding of arbitrary topics (episode.py) and of compressed images in the transform still uses mcap_protobuf and mcap_ros2.

Behavior bump

TRANSFORM_BEHAVIOR_VERSION moves from 12 to 13. The transform writes different bytes for the same input:

  • The foxglove.CompressedVideo schema record now carries protobuf json_name entries. Readers treat it the same.
  • The library identifier is hebbian-mcap/0.1.1.
  • A pass-through protobuf message that gains an access unit delimiter keeps its original field order.

Decoded message content is unchanged. Regenerate derived outputs from the source recordings.

Dependencies

  • hebbian-mcap pin moves from 0.1.0 to 0.1.1.
  • foxglove-schemas-protobuf moves from runtime dependencies to the dev group, because only tests import it. Code that relied on HFlow installing it needs to depend on it directly.

Tests

test_transform_preserves_decoder_owned_video_messages monkeypatched the removed decoder path. It is now test_transform_preserves_every_field_of_passthrough_video_messages and asserts on the written file: the recorder's extra original field survives for CDR, and the payload, format and frame are intact for both encodings.

Validation

uv run ruff check --fix
uv run ruff format
uv run ty check
uv run pytest -q -n auto   # 2647 passed, 8 skipped

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…p 0.1.1

The video importer, LeRobot importer and transform build CompressedVideo
messages and the schema record with the shared Rust encoder. Transform and
doctor read pass-through video through CompressedVideoCodec, which walks ROS 2
CDR by the channel's schema and replaces protobuf payloads at the wire level,
so the Python re-encoding workaround is removed.

Bump TRANSFORM_BEHAVIOR_VERSION to 13: the schema record and library
identifier change, and repaired protobuf messages keep their field order.
foxglove-schemas-protobuf moves to the dev group because only tests import it.
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were established.

Summary

Moves video message encoding and payload replacement into hebbian-mcap 0.1.1.

  • Video imports and transformed frames use the shared message encoder.
  • Pass-through video keeps its other message fields when its payload changes.
  • Doctor checks video through the shared compressed-video codec.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Video and LeRobot importers] --> B[encode_compressed_video]
  C[Transform image encoding] --> B
  D[Recorded video messages] --> E[CompressedVideoCodec.decode]
  E --> F[Transform video checks]
  F --> G{AUD missing?}
  G -->|Yes| H[CompressedVideoCodec.replace_data]
  G -->|No| I[Keep original message]
  B --> J[Write MCAP]
  H --> J
  I --> J
  E --> K[Doctor video checks]
Loading

Reviews (1) · Last reviewed commit: "refactor(mcap): encode and rewrite video..." · Reviewed by Greptile

@kstonekuan
kstonekuan merged commit fc2411b into main Nov 15, 2026
5 checks passed
@kstonekuan
kstonekuan deleted the use-native-mcap-encoders branch November 15, 2026 10:40
@kstonekuan kstonekuan mentioned this pull request Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant