Robotics StackExchange | Archived questions

Call video_recorder Start & stop via topic

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 videorecorder via Launshing Topic "starttopic" ,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 videorecorder. I want to stop recording via topic like the "starttopic".. 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 ?

Asked by Tayssir Boubaker on 2020-11-10 06:21:31 UTC

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)

Asked by Tayssir Boubaker on 2020-11-14 03:43:39 UTC

Answers