This is a code to read data from ros2 bag & record data to ros2 bag. Example for getting RealSense/Feynman camera data from a bag & record data to bag.
If you encounter problems with cv_bridge, you can refer to https://sxij.xyz/posts/ros_cv_bridge/ .