Items with no label
3335 Discussions

enable_record_to_file slow

APu
New Contributor I
2,051 Views

I'm currently using Python 3.7 with pyrealsense2 on Windows 10.

My end goal is to be able to preview a rgb stream while recording both depth and rgb to disk.

However, when I stream only to disk with enable_record_to_file(), I realize that I drop frames. Is this normal? When I use the realsense viewer to record, everything looks fine, so I'm not sure what's wrong.

I set the configuration enable_stream to 30 fps, but it's clear that the videos of the exported bag files do not reflect that.

0 Kudos
3 Replies
MartyG
Honored Contributor III
754 Views

I have dealt with several cases where frames are dropped during recording. Here's an example:

0 Kudos
APu
New Contributor I
754 Views

Thank you for the response.

I tried using keep() and I do not drop frames anymore. However, when I try to take a 20 second video, I realize my video is only 9 seconds. I realized the rosbag video cuts off prematurely, before all 20 seconds of the streams are written to the bag.

My code is as follows:

pipeline = rs.pipeline()

config = rs.config()

config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)

config.enable_stream(rs.stream.color, 640, 480, rs.format.rgb8, 30)

config.enable_record_to_file('test.bag')

pipeline.start(config)

try:

start = time.time()

while time.time()-start < 20:

pipeline.wait_for_frames().keep()

finally:

pipeline.stop()

I'm guessing that the pipeline stops when only 9 seconds of the stream has been written to the bag.

Is there a workaround for this?

Thanks in advance!

0 Kudos
MartyG
Honored Contributor III
754 Views

With rosbags, you can set a maximum duration for a recording. I believe that in Librealsense, the TIME_MAX instruction is used for this.

https://github.com/IntelRealSense/librealsense/search?q=TIME_MAX&unscoped_q=TIME_MAX Search · TIME_MAX · GitHub

For a well-informed answer about how to write a TIME_MAX instruction, posting a help request on the RealSense 'Issues' GitHub would be a good move. On the Issues page, you can click the 'New issues' button to post a question.

https://github.com/IntelRealSense/librealsense/issues Issues · IntelRealSense/librealsense · GitHub

0 Kudos
Reply