librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Recording multiple clips consecutively

Open upxela opened this issue 8 years ago • 14 comments

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model D400
Firmware Version 5.10.3
Operating System & Version Win 10
Platform PC
SDK Version 2.14.0
Language python2.7

Issue Description

I am looking to recording many shorter, consecutive videos (~2 minutes in length) rather than one large video (which may amount to 24+ hours). Therefore it is desirable that there is not much lost between videos. Unfortunately my code that between closing a pipeline and starting the pipeline again, it takes approximately 0.6 seconds, which is not optimal for my application. Does anyone have any suggestions for workarounds for this?

upxela avatar Sep 20 '18 17:09 upxela

If you are recording rosbags, ROS has a --split command that splits the bag when a maximum duration or file size is reached.

Examples:

$ rosbag record --split --size=1024 /chatter $ rosbag record --split --duration=30 /chatter $ rosbag record --split --duration=5m /chatter $ rosbag record --split --duration=2h /chatter

http://wiki.ros.org/rosbag/Commandline#record

MartyG-RealSense avatar Sep 20 '18 18:09 MartyG-RealSense

@MartyG-RealSense Thanks for the reply! Do you know how I would use this in tandem with the realsense api, specifically the pipeline start/close commands?

upxela avatar Sep 20 '18 19:09 upxela

My experience with ROS is limited and one of the Intel team can give better advice on it. You should be able to use the SDK's ROS wrapper though to use the SDK and ROS together.

https://github.com/intel-ros/realsense/releases

MartyG-RealSense avatar Sep 20 '18 19:09 MartyG-RealSense

It looks like this method requires Linux. Are you aware of any Windows-friendly methods to obtain the same result?

upxela avatar Sep 20 '18 19:09 upxela

There is a Windows version of the newest ROS 2, though it likely would not be able to talk to the SDK API through the ROS wrapper.

https://github.com/ros2/ros2/wiki/Windows-Install-Binary

ROS2 can be made compatible with the 400 Series cameras.

https://communities.intel.com/message/543051#543051

MartyG-RealSense avatar Sep 20 '18 19:09 MartyG-RealSense

An easier solution may be to try the developer UnaNancyOwen's recording program for SDK 2.0 to see if that gives you smaller file sizes.

https://github.com/UnaNancyOwen/RealSense2Sample/tree/master/sample/Record

Some developers also capture the stream as a sequence of PNG images instead of a bag to reduce file size.

MartyG-RealSense avatar Sep 20 '18 20:09 MartyG-RealSense

Thanks for the suggestions @MartyG-RealSense. As of right now, file size is not the main problem; the point of recording multiple shorter films is such that in the case of a file corruption, there is not as much of an impact if only 2 minutes are lost compared to 24 hours.

Additionally, I have seen problems with frame drops after 30 minutes when streaming full depth resolution with 4 cameras concurrently, which brings about the idea of using shorter clips to prevent as big of an impact should it happen during an important recording session.

upxela avatar Sep 21 '18 13:09 upxela

Intel's recent webinar on multiple cameras stated that if you position your four cameras so that their fields of view overlap then it provides more comprehensive depth data, because there is more redundancy in the data. If your four cameras are looking at approximately the same area, I wonder if this redundancy would help to fill gaps if one or more cameras drop some frames.

MartyG-RealSense avatar Sep 21 '18 13:09 MartyG-RealSense

Unfortunately, each camera in my application would be part of its own "system," i.e. camera 1 would not record anything that camera 2 is recording, etc. Therefore it is important for me to obtain a seamless video from each camera.

upxela avatar Sep 21 '18 13:09 upxela

It's a tricky situation you're dealing with. The SDK has a function called Keep(), where you can store frames in memory until the end of streaming and then save them, and do some post-processing on the frames too if you wish (though this adds to processing time). This way, you may lose less frames than if you are recording the frames as you go.

Keep() is best suited to short recording sequences, so it may be a good fit for how you are recording the data in multiple chunks/

Another option may be to use an industrial-grade USB hub and / or industrial-grade USB cable, though these are more expensive then regular USB equipment. Industrial grade equipment is used in applications such as medical scanners, where frame drops cannot be tolerated.

Mains wall-socket powered hubs are also very useful for increasing USB stability. In Intel's multiple-camera white paper, they tested with a cheap AmazonBasics hub that was AC adapter powered.

MartyG-RealSense avatar Sep 21 '18 14:09 MartyG-RealSense

@MartyG-RealSense frame dropping is currently not as big of an issue as just being able to record consecutive videos. I realized that to close a pipeline and restart can take up to approximately 1.5 seconds (~0.5 seconds to start, ~1 second to close), which is too long of a pause for my application.

Is there a way that I can redirect the file destination of my camera recording without closing the pipeline? I know that you previously mentioned using ROS, but I can't find any documentation that explains how to use it in tandem with realsense.

upxela avatar Oct 09 '18 18:10 upxela

I carefully went over the code of the SDK's record and playback sample program.

https://github.com/IntelRealSense/librealsense/tree/master/examples/record-playback

Whilst it may be possible to change the path with code by having the filename as a number (e.g 1.bag) and incrementing it by 1 with a command, I could not see a way to start another file without first stopping the pipeline. It is the stopping of the pipeline that releases currently held resources, including the bag file that was being recorded.

One of the Intel guys may be able to offer further suggestions.

MartyG-RealSense avatar Oct 10 '18 07:10 MartyG-RealSense

Thanks for the insight @MartyG-RealSense! Hopefully someone from Intel can find a workaround.

upxela avatar Oct 10 '18 13:10 upxela

[Realsense Customer Engineering Team Comment] Ticket being closed due to inactivity for 30+ days