3 Replies Latest reply on Jul 30, 2018 1:09 PM by MartyG

    enable_record_to_file slow


      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.

        • 1. Re: enable_record_to_file slow

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


          Program skipping frames

          • 2. Re: enable_record_to_file slow

            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)
                start = time.time()
                while time.time()-start < 20:


            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!

            • 3. Re: enable_record_to_file slow

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


              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.


              Issues · IntelRealSense/librealsense · GitHub