Recording video file with gstreamer and python script

asked 2019-03-10 06:43:54 -0600

updated 2019-03-10 07:42:21 -0600

berak gravatar image

Hello

Trying to use ROS+OpenCV+Gstreamer to write to a file. I am using the compressedImage message from a USB Camera in order to record a mp4 file.

Some reason python script is not able to run properly. I configure VideoWriter as:

  if self.output_path:
            self.video_writer = cv2.VideoWriter("appsrc ! videoconvert ! avenc_h264 ! matroskamux ! filesink location=/home/hel/test.mp4", 0, 30, (640, 480))

ROS output has:

[rospy.client][INFO] 2019-03-10 07:35:15,502: init_node, name[/video_recorder], pid[20053]
[xmlrpc][INFO] 2019-03-10 07:35:15,503: XML-RPC server binding to 0.0.0.0:0
[xmlrpc][INFO] 2019-03-10 07:35:15,504: Started XML-RPC server [http://heldev:42449/]
[rospy.init][INFO] 2019-03-10 07:35:15,505: ROS Slave URI: [http://heldev:42449/]
[rospy.impl.masterslave][INFO] 2019-03-10 07:35:15,505: _ready: http://heldev:42449/
[rospy.registration][INFO] 2019-03-10 07:35:15,507: Registering with master node http://localhost:11311
[xmlrpc][INFO] 2019-03-10 07:35:15,507: xml rpc node: starting XML-RPC server
[rospy.init][INFO] 2019-03-10 07:35:15,606: registered with master
[rospy.rosout][INFO] 2019-03-10 07:35:15,606: initializing /rosout core topic
[rospy.rosout][INFO] 2019-03-10 07:35:15,613: connected to core topic /rosout
[rospy.simtime][INFO] 2019-03-10 07:35:15,616: /use_sim_time is not set, will not subscribe to simulated time [/clock] topic
[rospy.internal][INFO] 2019-03-10 07:35:15,675: topic[/camera1/image_raw/compressed] adding connection to [http://heldev:34701/], count 0
[rospy.internal][INFO] 2019-03-10 07:35:15,852: topic[/rosout] adding connection to [/rosout], count 0
[rospy.core][INFO] 2019-03-10 07:36:06,050: signal_shutdown [signal-2]
[rospy.internal][INFO] 2019-03-10 07:36:06,069: topic[/rosout] removing connection to /rosout
[rospy.internal][INFO] 2019-03-10 07:36:06,070: topic[/camera1/image_raw/compressed] removing connection to http://heldev:34701/
[rospy.impl.masterslave][INFO] 2019-03-10 07:36:06,071: signal-2
[rosout][INFO] 2019-03-10 07:36:06,186: [ros-video-recorder] Video Saved. path=/home/hel/usb_cam1.mp4
[rosout][INFO] 2019-03-10 07:36:06,252: [ros-video-recorder] Video Saved. path=/home/hel/usb_cam1.mp4
[rospy.core][INFO] 2019-03-10 07:36:06,254: signal_shutdown [atexit]

During runtime ROS shows:

OpenCV: FFMPEG: tag 0x00000000/'????' is not supported with codec id 14 and format 'mp4 / MP4 (MPEG-4 Part 14)'
  int (Brightness, 0, id = 980900): -64 to 64 (1)
  int (Contrast, 0, id = 980901): 0 to 64 (1)
  int (Saturation, 0, id = 980902): 0 to 128 (1)
  int (Hue, 0, id = 980903): -40 to 40 (1)
  bool (White Balance Temperature, Auto, 0, id = 98090c): 0 to 1 (1)
  int (Gamma, 0, id = 980910): 72 to 500 (1)
  int (Gain, 0, id = 980913): 0 to 100 (1)
  menu (Power Line Frequency, 0, id = 980918): 0 to 2 (1)
    0: Disabled
    1: 50 Hz
    2: 60 Hz
  int (White Balance Temperature, 16, id = 98091a): 2800 to 6500 (1)
  int (Sharpness, 0, id = 98091b): 0 to 6 (1)
  int (Backlight Compensation, 0, id = 98091c): 0 to 2 (1)
  menu (Exposure, Auto, 0, id = 9a0901): 0 to 3 (1)
  int (Exposure (Absolute), 16, id ...
(more)
edit retag flag offensive close merge delete