gazebosim / gz-common

An audio-visual library supports processing audio and video files, a graphics library can load a variety 3D mesh file formats into a generic in-memory representation, and the core library of Gazebo Common contains functionality that spans Base64 encoding/decoding to thread pools.
https://gazebosim.org
Apache License 2.0
12 stars 38 forks source link

VideoEncoder does not encode to v4l2 loopback device #544

Open vryabokon1705 opened 11 months ago

vryabokon1705 commented 11 months ago

Environment

Description

Steps to reproduce

  1. Build fork of regular CameraVideoRecorder plugin with possibility to use v4l2 format : https://github.com/vryabokon1705/camera-videro-recorder2.git
  2. Copy libCameraVideoRecorder2.so to $HOME/.gz/sim/plugins/
  3. Make copy of camera_video_record_dbl_pendulum.sdf as camera_video_record_dbl_pendulum_copy.sdf
  4. Edit camera_video_record_dbl_pendulum_copy.sdf: <sensor name="camera" type="camera"> <plugin filename="CameraVideoRecorder2" name="streamer::CameraVideoRecorder2"> <service>camera/record_video</service> </plugin> ... </sensor>
  5. Check existing v4l2 devices ls /dev/video*
  6. Create v4l2 loopback device: sudo modprobe v4l2loopback find new created v4l2 loopback device path (let it be /dev/video1) ls /dev/video*
  7. Start gazebo simulator: gz sim camera_video_record_dbl_pendulum_copy.sdf
  8. Start gazebo service: gz service -s /camera/record_video --reqtype gz.msgs.VideoRecord --reptype gz.msgs.Boolean --timeout 300 --req 'start: true, format:"v4l2", save_filename:"/dev/video1"'

Output

image image

vryabokon1705 commented 11 months ago

Looks like line 349 this->dataPtr->format = _format.compare("v4l") == 0 ? "v4l2" : _format; must be replaced with this->dataPtr->format = _format.compare("v4l") == 0 || _format.compare("v4l2") == 0 ? "video4linux2,v4l2" : _format;

mjcarroll commented 10 months ago

@vryabokon1705 any chance you could open a PR with that?