usb_cam
usb_cam copied to clipboard
Store and replay video streams
Many webcams provide compressed streams. When video data is stored to disk it is also compressed. A video driver that uncompresses data for ROS sensor_msgs/Image messages, and a second node that compresses it again to store video adds significant processing overhead, as video stream compression is expensive. This is undesirable especially on embedded robotic hardware.
It would be much more convenient to dump the already compressed stream into a file, and later replay that - as if it came from a camera. This makes it necessary to add frame headers to include metadata (such as ROS::Time stamps)
The modification in this branch/pull request make this possible. A parameter to the node specifies a filename in which the stream is to be stored. Recording can be turned on and off at any time - irrespective of whether the camera is capturing with a ROS message the node listens to.
Replaying the recorded stream can be done by using the file as a "video device"
To watch recorded streams, a separate script (written in C) - streamcat - pipes the stream to stdout, It can then be re-encoded with ffmpeg - streamed over the web, or watched with ffplay.
Recording adds a tiny bit of I/O overhead, but almost no CPU overhead, as existing buffers are used on the fly.
I'm happy to discuss modifications to this if desired.