Call video_recorder Start & stop via topic

asked 2020-11-10 05:21:31 -0500

Tayssir Boubaker gravatar image

Hi,

I am using the video_recorder to save a video stream to a file using ros.This is the command I am using :

rosrun image_view video_recorder image:=/camera/image_raw  _filename:="test.avi"

These are the messages in the terminal :

[ INFO] [1548243269.519044136]: Waiting for topic /camera/color/image_raw...
[ INFO] [1548243269.722238288]: Starting to record MJPG video at [640 x 480]@15fps. Press Ctrl+C to stop recording.
[ INFO] [1548243271.470604124]: Recording frame 52
 Video saved as output.avi

Now, I want to call the video_recorder via Launshing Topic "start_topic" ,So I tried to call this funcition via subprocess.Peopen like that :

cmd = rosrun image_view video_recorder image:=/camera/image_raw  _filename:="test.avi"
proc = subprocess.Popen(cmd, shell=True)

It works but I can't stop video_recorder. I want to stop recording via topic like the "start_topic".. I tried to kill the process ..use function subprocess.terminte() .. But it does not work.

Does anyone know what's wrong? Any Help to stop the record without tapping Ctr+C ?

edit retag flag offensive close merge delete

Comments

I solve it , I hope this will help someone. I shared with everyone found it helpful: As was written above, I tried to kill proc.pid and it dosent work .. So,I tried to follow the PID with htop or ps -ax and i discover that am killing the wrong PID. The correct one is

 os.kill(proc.pid+1, signal.SIGTERM)
Tayssir Boubaker gravatar image Tayssir Boubaker  ( 2020-11-14 02:43:39 -0500 )edit