Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img_transmission

A collection of tools for low-latency transmission of compressed images over wired and wireless networks using GStreamer and ROS 2.

This repository provides two solutions to efficiently transmit images between two computing units (PCs, servers, robots, etc.) using either a wired or wireless connection.

The two proposed approaches are:

  1. GStreamer-based video streaming
  2. ROS 2 image transport using FFmpeg compression

Docker usage

This repository provides a Docker environment to easily reproduce the image transmission experiments.

The Docker image contains all required dependencies, including ROS 2 Humble, FFmpeg image transport, GStreamer, and Cyclone DDS support.

Build the Docker image

To build the Docker image, run:

make build

Run the Docker container

An interactive shell can be started with:

make shell

Start a GStreamer sender:

make gstreamer_sender HOST=127.0.0.1

Start a GStreamer receiver:

make gstreamer_receiver

Start the H.264 encoder:

make ffmpeg_encoder

Start the H.264 decoder:

make ffmpeg_decoder

1. GStreamer

GStreamer is used to capture, compress, transmit, and decode video streams with low latency.

Find camera devices

Before using GStreamer, identify the available video devices:

ls -l /dev/video*

Local camera test

This command captures a local camera stream and displays it locally. It is only used to verify that the camera and GStreamer pipeline are working correctly:

gst-launch-1.0 v4l2src device=/dev/video6 ! \
video/x-raw,format=YUY2,width=1280,height=720,framerate=30/1 ! \
queue leaky=downstream max-size-buffers=1 ! \
videoconvert ! \
autovideosink sync=false

Streaming between two PCs

For local testing, use:

host=127.0.0.1

For communication between two computers, replace it with the receiver IP address:

udpsink host=<RECEIVER_PC_IP> port=5000

PC1 - Sender

gst-launch-1.0 -v \
v4l2src device=/dev/video6 ! \
video/x-raw,format=YUY2,width=1920,height=1080,framerate=30/1 ! \
videoconvert ! \
queue leaky=downstream max-size-buffers=1 ! \
x264enc tune=zerolatency speed-preset=ultrafast bitrate=4000 key-int-max=15 ! \
rtph264pay config-interval=1 pt=96 ! \
udpsink host=127.0.0.1 port=5000

Main parameters:

  • tune=zerolatency: reduces encoding latency
  • speed-preset=ultrafast: prioritizes speed over compression efficiency
  • bitrate=4000: H.264 bitrate in kbps
  • key-int-max=15: controls keyframe interval

PC2 - Receiver

gst-launch-1.0 -v \
udpsrc port=5000 \
caps="application/x-rtp,media=video,encoding-name=H264,payload=96" ! \
rtpjitterbuffer latency=0 ! \
rtph264depay ! \
queue leaky=downstream max-size-buffers=1 ! \
avdec_h264 ! \
videoconvert ! \
fpsdisplaysink video-sink=autovideosink sync=false text-overlay=true

2. ROS 2 FFmpeg image transport

The second approach uses ROS 2 image_transport with FFmpeg compression.

Install the required package:

sudo apt install ros-humble-ffmpeg-image-transport

Image compression (encoder)

Example: compress a raw ROS 2 image topic using H.264:

ros2 run image_transport republish raw ffmpeg \
--ros-args \
--remap in:=/camera/camera/color/image_raw \
--remap out/ffmpeg:=/camera/color_ffmpeg \
-p out.ffmpeg.bit_rate:=400000 \
-p out.ffmpeg.encoder:=libx264 \
-p out.ffmpeg.qmax:=20 \
-p out.ffmpeg.gop_size:=10 \
-p out.ffmpeg.max_b_frames:=0 \
-p out.ffmpeg.encoder_av_options:="preset:ultrafast,tune:zerolatency"

Image decompression (decoder)

Decode the compressed stream back to a raw ROS 2 image:

ros2 run image_transport republish ffmpeg raw \
--ros-args \
--remap __node:=ffmpeg_decoder \
--remap in/ffmpeg:=/camera/color_ffmpeg \
--remap out:=/camera/color_raw \
-p in.ffmpeg.decoders.h264:=h264

Requirements

  • Ubuntu 22.04
  • ROS 2 Humble (for the FFmpeg ROS 2 option)
  • GStreamer
  • H.264 encoder/decoder support

Contributors

Amaury Saint-Jore

About

Optimized transmission of compressed images over wired and wireless networks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages