Skip to main content

A tool to convert ROS topics recored with mcap to MP4 file

Project description

mcap-to-mp4

A tool to convert ROS 2 topics recorded with rosbag2 recordings in mcap format into MP4 files

English
This tool provides a simple way to convert ROS 2 topics stored in rosbag2 recordings using the MCAP format into standard MP4 video files.
It is especially useful for visualizing and sharing regularly published topics such as camera streams or sensor data.
Since the tool assumes that topics are subscribed at a fixed rate, the generated MP4 uses the average frame interval of the input messages.
This makes the resulting video well-suited for experiment reviews, demos, or presentations.

日本語
このツールは、rosbag2MCAP 形式として記録された ROS 2 トピックを、標準的な MP4 動画ファイルに変換します。
カメラストリームやセンサーデータなど、一定周期で発行されるトピックを可視化・共有するのに特に便利です。
トピックが一定周期でサブスクライブできることを前提としており、生成される MP4 は各フレーム間隔の平均値を採用して出力します。
そのため、実験の振り返りやデモ、プレゼンテーションに適しています。

Requirements

Note: This tool does NOT require a ROS 2 runtime environment.
You only need Python and the following dependencies:

  • Python3
    • mcap
    • mcap-ros2-support
    • poetry
    • pillow
    • numpy
    • imageio
  • ffmpeg

QuickStart

pip

# Install
pip install mcap-to-mp4
# Run
mcap-to-mp4 $path_to_the_mcap_file -t $topic_name -o $outputfilename

Docker

# Build
git clone https://github.com/Tiryoh/mcap-to-mp4.git
docker build -t tiryoh/mcap-to-mp4 .
# Run
docker run --rm -it -v "${PWD}:/works" tiryoh/mcap-to-mp4 $path_to_the_mcap_file -t $topic_name -o $outputfilename

Usage

pip

Install the package from PyPI

pip install mcap-to-mp4

Install the pacakge from source (optional)

# optional
git clone https://github.com/Tiryoh/mcap-to-mp4.git
pip install -e .

Download sample mcap rosbag2 file

wget "https://drive.usercontent.google.com/download?id=1TxKxq-SN_9ryiFxH6kQG07Gy90_bpnWW&confirm=xxx" -O "realsense_rosbag2.zip"
unzip realsense_rosbag2.zip

Run

mcap-to-mp4 ./rosbag2_2024_02_18-23_35_48/rosbag2_2024_02_18-23_35_48_0.mcap -t /camera/color/image_raw -o output.mp4

Docker

Install the package

git clone https://github.com/Tiryoh/mcap-to-mp4.git
docker build -t tiryoh/mcap-to-mp4 .

Download sample mcap rosbag2 file

wget "https://drive.usercontent.google.com/download?id=1TxKxq-SN_9ryiFxH6kQG07Gy90_bpnWW&confirm=xxx" -O "realsense_rosbag2.zip"
unzip realsense_rosbag2.zip

Run

docker run --rm -it -v "${PWD}:/works" tiryoh/mcap-to-mp4 ./rosbag2_2024_02_18-23_35_48/rosbag2_2024_02_18-23_35_48_0.mcap -t /camera/color/image_raw -o output.mp4

License

Copyright 2024 Daisuke Sato

This repository is licensed under the MIT license, see LICENSE.
Unless attributed otherwise, everything in this repository is under the MIT license.

Related Projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcap_to_mp4-0.3.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcap_to_mp4-0.3.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file mcap_to_mp4-0.3.0.tar.gz.

File metadata

  • Download URL: mcap_to_mp4-0.3.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcap_to_mp4-0.3.0.tar.gz
Algorithm Hash digest
SHA256 751e59a8b29289c5d4277770575898c4bca91b964381ade93c7404e1533cddd0
MD5 fd234d5d4061e58d65965ba2b4714138
BLAKE2b-256 9c7babca3506c3209d82dd200f7e9200c9c0f6caaf1f9053d0351476a658cd61

See more details on using hashes here.

File details

Details for the file mcap_to_mp4-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mcap_to_mp4-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mcap_to_mp4-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e026751b5d9fa0b920ece55da480c1bbd0c84c801f4cd52954a471dc5409becd
MD5 150cab45876b616b046c3c16defaa437
BLAKE2b-256 599b7dba3f22498a0e15e073215a0dc275c6a8f6721c65a95c4c8d89204a9a61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page