#15577·librealsense

[Question] Loading one-frame bag files causes error `RunTimeError: Frame did not arrive within 5000`

Author: poroc300Created Aug 18, 2026Updated Sep 3, 2026
Labelsquestion

Camera Model (if applicable)

D435i

Topic

Python Wrapper

Your Question

I've recorded several one-frame bag files with a RealSense camera and I am trying to load the colour and depth frame from the .bag file using pyrealsense2.

This is the code I am using:

# configure pipeline to read from a bag file rather than a physical camera device
pipeline = rs.pipeline()
config = rs.config()
config.enable_device_from_file(str(bag_path), repeat_playback=True)
config.enable_all_streams()

 try:
        # retrieve the colour-camera intrinsics, these are required later
        # when converting image coordinates into real-world 3D coordinates.
        profile = pipeline.start(config)
        playback = profile.get_device().as_playback()
        playback.set_real_time(False)
        
        intrinsics = (
            profile.get_stream(rs.stream.color)
            .as_video_stream_profile()
            .get_intrinsics()
        )
        depth_scale = profile.get_device().first_depth_sensor().get_depth_scale()
        align = rs.align(rs.stream.color)
                
        try:
            frame = pipeline.wait_for_frames(timeout_ms=5000)
        except RuntimeError:
            raise RuntimeError("could not retrieve frame from bag file")

  finally:
      pipeline.stop()

This code works fine for Python versions 3.8-3.11 and with pyrealsense2 version < 2.56. However, for 2.56 and above, the code raises a RunTimeError: Frame did not arrive within 5000 when it hits pipeline.wait_for_frames.

I've seen a couple other issues with the same error, but not exactly with one-frame bag files.

I am wondering if the API changed significantly since v2.56 and how should I change the above code to read the frame from the one-frame bag file?

Context / What You've Tried

I've validated the code with versions of pyrealsense2 < v2.56, which indicates that there might have been a change in behaviour in the API. Ideally, for security purposes, I would like to run the code above in more recent versions of Python.

LibRealSense SDK Version (if applicable)

2.56

Operating System (if applicable)

Ubuntu 22.04

Additional Context

No response

Source: realsenseai/librealsense