README.md 6.26 KB
Newer Older
1 2 3 4
# QGroundControl

## Video Streaming

5
For supported platforms, QGroundControl implements an UDP RTP and RSTP video streaming receiver in its Main Flight Display. It uses GStreamer and a stripped down version of QtGstreamer. We've standardized on **GStreamer 1.14.4**. It has been reliable and we will be using it until a good reason to change it surfaces. Newer versions of GStreamer may break the build as some dependent libraries may change.
Gus Grubba's avatar
Gus Grubba committed
6 7 8 9
To build video streaming support, you will need to install the GStreamer development packages for the desired target platform.

If you do have the proper GStreamer development libraries installed where QGC looks for it, the QGC build system will automatically use it and build video streaming support. If you would like to disable video streaming support, you can add **DISABLE_VIDEOSTREAMING** to the **DEFINES** build variable.

10 11 12 13
### Gstreamer logs

For cases, when it is need to have more control over gstreamer logging than is availabe via QGroundControl's UI, it is possible to configure gstreamer logging via environment variables. Please see https://developer.gnome.org/gstreamer/stable/gst-running.html for details.

Gus Grubba's avatar
Gus Grubba committed
14
### UDP Pipeline
Gus Grubba's avatar
Gus Grubba committed
15

Gus Grubba's avatar
Gus Grubba committed
16
For the time being, the RTP UDP pipeline is somewhat hardcoded, using h.264 or h.265. It's best to use a camera capable of hardware encoding either h.264 (such as the Logitech C920) or h.265. On the sender end, for RTP (UDP Streaming) you would run something like this:
Gus Grubba's avatar
Gus Grubba committed
17

Gus Grubba's avatar
Gus Grubba committed
18
h.264
Gus Grubba's avatar
Gus Grubba committed
19
```
Don Gagne's avatar
Don Gagne committed
20
gst-launch-1.0 uvch264src initial-bitrate=1000000 average-bitrate=1000000 iframe-period=1000 device=/dev/video0 name=src auto-start=true src.vidsrc ! video/x-h264,width=1920,height=1080,framerate=24/1 ! h264parse ! rtph264pay ! udpsink host=xxx.xxx.xxx.xxx port=5600
Gus Grubba's avatar
Gus Grubba committed
21 22
```

Gus Grubba's avatar
Gus Grubba committed
23 24 25 26 27 28 29
h.265
```
ffmpeg -f v4l2 -i /dev/video1 -pix_fmt yuv420p -c:v libx265 -preset ultrafast -x265-params crf=23 -strict experimental -f rtp udp://xxx.xxx.xxx.xxx:5600
```

Where xxx.xxx.xxx.xxx is the IP address where QGC is running.

Gus Grubba's avatar
Gus Grubba committed
30

31 32
To test using a test source on localhost, you can run this command:
```
33
gst-launch-1.0 videotestsrc pattern=ball ! video/x-raw,width=640,height=480 ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5600
34
```
35 36 37 38
Or this one:
```
gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=5600
```
39

Gus Grubba's avatar
Gus Grubba committed
40 41
On the receiving end, if you want to test it from the command line, you can use something like:
```
42
gst-launch-1.0 udpsrc port=5600 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink fps-update-interval=1000 sync=false
Gus Grubba's avatar
Gus Grubba committed
43 44
```

Gus Grubba's avatar
Gus Grubba committed
45 46 47 48
### Additional Protocols

QGC also supports RTSP, TCP-MPEG2 and MPEG-TS (h.264) pipelines.

Gus Grubba's avatar
Gus Grubba committed
49 50 51 52
### Linux

Use apt-get to install GStreamer 1.0
```
53 54 55 56
list=$(apt-cache --names-only search ^gstreamer1.0-* | awk '{ print $1 }' | grep -v gstreamer1.0-hybris)
```
```
sudo apt-get install $list
Gus Grubba's avatar
Gus Grubba committed
57
```
58 59 60
```
sudo apt-get install libgstreamer-plugins-base1.0-dev
```
Gus Grubba's avatar
Gus Grubba committed
61 62 63 64 65

The build system is setup to use pkgconfig and it will find the necessary headers and libraries automatically.

### Mac OS

66
Download the gstreamer framework from here: http://gstreamer.freedesktop.org/data/pkg/osx. Supported version is 1.14.4. QGC may work with newer version, but it is untested.
Gus Grubba's avatar
Gus Grubba committed
67

Gus Grubba's avatar
Gus Grubba committed
68
You need two packages:
69 70
- [gstreamer-1.0-devel-1.14.4-x86_64.pkg](https://gstreamer.freedesktop.org/data/pkg/osx/1.14.4/gstreamer-1.0-devel-1.14.4-x86_64.pkg)
- [gstreamer-1.0-1.14.4-x86_64.pkg](https://gstreamer.freedesktop.org/data/pkg/osx/1.14.4/gstreamer-1.0-1.14.4-x86_64.pkg)
Gus Grubba's avatar
Gus Grubba committed
71 72

The installer places them under /Library/Frameworks/GStreamer.framework, which is where the QGC build system will look for it. That's all that is needed. When you build QGC and it finds the gstreamer framework, it automatically builds video streaming support.
Gus Grubba's avatar
Gus Grubba committed
73 74 75 76 77 78 79 80

:point_right: To run gstreamer commands from the command line, you can add the path to find them (either in ~/.profile or ~/.bashrc):
```
export PATH=$PATH:/Library/Frameworks/GStreamer.framework/Commands
```

### iOS

81
Download the gstreamer framework from here: [gstreamer-1.0-devel-1.14.4-ios-universal.pkg](https://gstreamer.freedesktop.org/data/pkg/ios/1.14.4/gstreamer-1.0-devel-1.14.4-ios-universal.pkg)
Gus Grubba's avatar
Gus Grubba committed
82 83

The installer places them under ~/Library/Developer/GStreamer/iPhone.sdk/GStreamer.framework, which is where the QGC build system will look for it. That's all that is needed. When you build QGC and it finds the gstreamer framework, it automatically builds video streaming support.
Gus Grubba's avatar
Gus Grubba committed
84 85 86

### Android

87
Download the gstreamer from here: [gstreamer-1.0-android-universal-1.14.4.tar.bz2](https://gstreamer.freedesktop.org/data/pkg/android/1.14.4/gstreamer-1.0-android-universal-1.14.4.tar.bz2)
88

89
Create a directory named "gstreamer-1.0-android-universal-1.14.4" under the root qgroundcontrol directory (the same directory qgroundcontrol.pro is located). Extract the downloaded archive under this directory. That's where the build system will look for it. Make sure your archive tool doesn't create any additional top level directories. The structure after extracting the archive should look like this:
Gus Grubba's avatar
Gus Grubba committed
90
```
91
qgroundcontrol
92 93 94
├── gstreamer-1.0-android-universal-1.14.4
│   │
│   ├──armv7
95
│   │   ├── bin
96 97 98 99 100
│   │   ├── etc
│   │   ├── include
│   │   ├── lib
│   │   └── share
│   ├──x86
Gus Grubba's avatar
Gus Grubba committed
101
```
Gus Grubba's avatar
Gus Grubba committed
102 103
### Windows

104
Download the gstreamer framework from here: http://gstreamer.freedesktop.org/data/pkg/windows. Supported version is 1.4.14. QGC may work with newer version, but it is untested.
Don Gagne's avatar
Don Gagne committed
105 106

You need two packages:
107 108 109 110 111 112 113 114

#### 32-Bit: 
- [gstreamer-1.0-devel-x86-1.14.4.msi](https://gstreamer.freedesktop.org/data/pkg/windows/1.14.4/gstreamer-1.0-devel-x86-1.14.4.msi)
- [gstreamer-1.0-x86-1.14.4.msi](https://gstreamer.freedesktop.org/data/pkg/windows/1.14.4/gstreamer-1.0-x86-1.14.4.msi)

#### 64-Bit: 
- [gstreamer-1.0-devel-x86_64-1.14.4.msi](https://gstreamer.freedesktop.org/data/pkg/windows/1.14.4/gstreamer-1.0-devel-x86_64-1.14.4.msi)
- [gstreamer-1.0-x86_64-1.14.4.msi](https://gstreamer.freedesktop.org/data/pkg/windows/1.14.4/gstreamer-1.0-x86_64-1.14.4.msi)
115

116
Make sure you select "Complete" installation instead of "Typical" installation during the install process. The installer places them under c:\gstreamer, which is where the QGC build system will look for it.