[ROS2] Stream Video via Gstreamer

asked 2019-07-01 16:16:24 -0500

nicoj gravatar image


I'm currently trying to get a RTSP Stream from a drone carrying a Nvidia Jetson TX2 with Ubuntu 18.04 and ROS2 Dashing to a ground station via wifi. What I was thinking about is using a client node and a server node to get it done. I have modeled a custom service which receives IP and Port and a start/stop boolean to start or stop the stream. As an response it sends a message with status. The service on the tx2 would then start a Gstreamer loop to send the video feed to said IP and Port.

The client node should also be able to turn the video feed off and on again, but only one video feed should run at a time. My question would be: Should I put the gstreamer loop in a second server node and would this node be controllable via interrupts for example or what would be best practice here?

The reationale is that I assume the GStreamer continuous sending and the ROS2 spin() might not work together, so it would not be possible to stop the thing once it's started

Any help is really appreciated



The service msgs look like following:

bool should_film #turns the stream on and off
string ipv4_addr #can be either ipv4
string ipv6_addr #or ipv6
string port 
bool successful
string return_msg

The Gstreamer Pipeline looks like following:

nvarguscamerasrc ! \
'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, \
format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h264enc \
maxperf-enable=1 bitrate=8000000 ! h264parse ! rtph264pay mtu=1400 ! udpsink host=192.168.x.x port=12345 sync=false async=false
edit retag flag offensive close merge delete


You can run gstreamer in separate node or use a different thread loop to run it. I assume you are using gstreamer c++ apis to parse the pipeline.

Tal Ma gravatar imageTal Ma ( 2019-10-17 07:26:20 -0500 )edit