Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the first X frames from a recorded bagfile #5848

Open
g2-bernotas opened this issue Feb 14, 2020 · 4 comments
Open

Remove the first X frames from a recorded bagfile #5848

g2-bernotas opened this issue Feb 14, 2020 · 4 comments

Comments

@g2-bernotas
Copy link

g2-bernotas commented Feb 14, 2020


Required Info
Camera Model D400
Operating System & Version Win (8.1/10)
Platform PC
Language C++/python

Issue Description

I have recorded bagfiles using my developed solution, which is similar to the one provided in the RS-Record-Playback example, except I used to pause/resume the recording (#4633).

I noticed that while the camera was being set-up as a recorder before it is being paused (the following line), it would have already started to record (0-3 seconds). As I do not want this information for my processing, I was wondering how can I remove these frames. I have looked around the Internet and Github repository for splitting/cropping the bagfiles files (ros_bag_splitter.py, cut.py, ROS filter, #1868); however, I couldn't find an easy solution, especially the one that does not involve working with ROS (rs-convert tool provides frames only, but not a new, shorter, bagfile).

I can skip a predefined number of frames during my processing; however, the number of unusable frames varies from file to file (I have over 1,000 files where the front padding ranges from 0 to 3 seconds, so from 0 to 90 frames at 30 FPS meaning that a single suits-it-all number does not work (I could choose the biggest number (90), but then I would lose a lot of data for the one that has no front padding). Another option would be to create a list of how many unnecessary frames each file has at the beginning; however, this could easily get lost, so I would rather have shorter bagfiles instead. I also thought of playing it from file and recording at the same time, but it seems it is unsupported.

My preferred language is Python, but it seems libraries such as pyrosbag are incomplete.

TL;DR: how to remove the first X frames from a bagfile, but have it as a shorter bagfile (not individual frames).

@MartyG-RealSense
Copy link
Collaborator

You covered every bag editing possibility that my own research could turn up. If your aim is to prevent the camera recording for the first few seconds after the camera starts, the easiest approach would likely be to simply pause the recording for a few seconds and then un-pause it.

Doing so with Python is discussed in the link below in a case where another user wanted to avoid recording the first couple of seconds whilst the camera settled down.

#4249

@g2-bernotas
Copy link
Author

@MartyG-RealSense thank you for your response. I will use the cut.py then or skip X frames. I was wondering if it would be possible to add such a feature (bagfile splitting/cutting) as an enhancement of the software you provide (in addition to the tools) as it might be relevant to other users as well that do not want to go the ROS path.

@MartyG-RealSense
Copy link
Collaborator

I've added the 'Enhancement' label to this post to tag it as a Feature Request that the RealSense developer team can track.

@antoniogrimalt
Copy link

@MartyG-RealSense thank you for your response. I will use the cut.py then or skip X frames. I was wondering if it would be possible to add such a feature (bagfile splitting/cutting) as an enhancement of the software you provide (in addition to the tools) as it might be relevant to other users as well that do not want to go the ROS path.

Hi @g2-bernotas, did you found a solution that produced .bag compatible with the RealSense Viewer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants