/camera_recorder

ROS service to programatically start and stop camera recordings

Primary LanguagePython

camera_recorder

This ROS package helps starting and stopping video recordings.

The intended use case is for users to configure the node either through command-line arguments or through the ~configure service and then start and stop individual recordings. The individual recordings could be one or several experiment runs that needs to be recorded.

Install

This package has a few requirements outside of ROS which needs to be installed before building, the dependencies are listed in requirements.txt file.

$ pip install -r requirements.txt

Interface

The interface for this node is mainly through the services ~start and ~stop. The ~start services takes as input the Record service which specifies the output filename (can also be complex path, the node will create folders as needed) and starts the recording. The recording will continue until either the node is shutdown or the user calls ~stop with the Trigger service. Users should ensure that success is true after each service call to ensure that everything went smoothly. Errors are reported in the message type of each service.

If the output format is different from the input source, ffmpeg will transcode on the fly. If this is not desired it is recommended to not apply any transformations, like hflip, and utilize the same format as the input source.

Configuration

The node can be configured either through parameters passed during startup, see init.launch, or through the ~configure service after the node is started. Configuration will take effect the next time the ~start service is called.

Examples

# Start the node with 720 resolution and 30fps
$ roslaunch camera_recorder init.launch size:=1280x720 rate:=30
# Record from different input source in raw format
$ roslaunch camera_recorder init.launch source:=/dev/video1 format:=yuyv422
# Additional arguments supported by launch file
$ roslaunch camera_recorder init.launch --ros-args

Checking supported streams

This package uses v4l2 to record data through ffmpeg. This places some restrictions on the format of the input stream and video sizes. To query your equipment use the following commands:

# List connected devices:
$ v4l2-ctl --list-devices
# List supported output formats, stream size and frames per second:
$ v4l2-ctl --list-formats-ext
# List supported formats for specific stream
$ ffmpeg -f v4l2 -list_formats all -i /dev/video0

Direct copy

If it is desired to avoid any-and-all processing of the input stream user should apply the copy option. This by-passes most processing by ffmpeg, but places restriction on what can be done. The copy option is incompatible with the vflip and hflip options and the output format is restricted to formats that can be directly copied from the input.