Skip to content

Commit 0ab0a31

Browse files
committed
Correct update lmao
1 parent 6334926 commit 0ab0a31

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

README.md

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Python3 examples for the usage of GStreamer in OpenCV
2-
<div style="text-align:center"><img src="https://i.imgflip.com/52sun5.jpg" width="400"/></div>
2+
<p align="center"><img src="https://i.imgflip.com/52sun5.jpg" width="400"/></p>
33

4-
## I give you the light of ~~Eärendil~~ GStreamer, our most beloved ~~star~~ lib. May it be a light for you in dark places, when all other lights go out.
4+
### I give you the light of ~~Eärendil~~ GStreamer, our most beloved ~~star~~ lib. May it be a light for you in dark places, when all other lights go out.
55

6-
These examples, written in Python, will provide a good starting point for a lot, and the most common, applications of GStreamer and OpenCV. The snippets include following functionalities:
6+
## Short intro
7+
These examples, written in Python, will provide a good starting point for a lot, and the most common, applications of GStreamer and OpenCV. The snippets mainly use OpenCV's VideoWriter and VideoCapture object, and include the following functionalities:
78
- Grabbing of standard OpenCV videocapture device
89
``` python
910
import cv2
@@ -47,12 +48,16 @@ appsink2file = "appsrc ! videoconvert ! mfxh264enc ! \
4748
```
4849
- Portable to CLI usage
4950

50-
As you are here, you probably know why you want to use GStreamer and OpenCV and I'm not gonna list all the advantages that GStreamer brings to the table.
51-
**However, if you find this repo helpful or even remotely funny, consider leaving a star.** Or not. Your choice.
51+
Since you are here, you probably know why you want to use GStreamer and OpenCV and I'm not gonna list all the advantages that GStreamer brings to the table. **However, if you find this repo helpful or even remotely funny, consider leaving a star.** Or not. Your choice.
5252

5353
# News
54+
- 2021-03-30 **Updated README; further install instructions; Raspi HW enc pipeline examples incoming**
5455
- 2021-03-23 **Updated README; preparation for nvidia examples**
5556
- 2021-03-01 **Updated for usage with Intel HD GPUs. NVIDIA examples as well as more complex stuff like splitting coming soon**
57+
58+
59+
60+
5661

5762
# Prerequisites
5863

@@ -75,26 +80,41 @@ As you are here, you probably know why you want to use GStreamer and OpenCV and
7580
- HW H264/H265 encoding and decoding
7681
- Bitrate control (CBR, VBR, CQP).
7782
- Selectable profiles up to High Profile.
78-
- Installation process (quite tedious):
79-
-
80-
- Follow https://github.com/intel/gstreamer-media-SDK to install MSDK and gst-msdk
83+
- Installation process (Honestly this is pretty frustrating Intel. I got very mad followed by getting drunk and yelling at the PC, but as far as i remember the process went something like this):
84+
- [LibVA](https://github.com/intel/libva)
85+
- [GmmLib](https://github.com/intel/gmmlib)
86+
- [Intel(R) Media Driver for VAAPI](https://github.com/intel/media-driver)
87+
- [Intel Media SDK](https://github.com/Intel-Media-SDK/MediaSDK#how-to-build)
88+
- [Gstreamer-Media-SDK](https://github.com/intel/gstreamer-media-SDK)
89+
90+
- Further instructions are [here](https://blogs.igalia.com/vjaquez/2018/11/23/building-gst-msdk-with-mediasdk-opensource/), [here](https://github.com/Intel-Media-SDK/MediaSDK#how-to-build)
8191
- Detailed examples [here](https://github.com/intel/gstreamer-media-SDK/blob/master/README.USAGE)
82-
- _(not easy to setup, especially with parallel CUDA configuration; be warned)_
83-
- _x264enc: 25 ms (Software) ; mfxh264enc: 1 ms (HW enc)_: Achieved speedup on 1920x1080 px
92+
- Achieved speedup for writing a Full-HD frame (1920x1080px) to NVMe SSD:
93+
- _x264enc (Software encoding)_: 25 ms
94+
- _mfxh264enc (Hardware encoding)_: 1 ms
8495
- _**NVIDIA GPUs**_
85-
- CUDA > 10.1, CuDNN > 7.5
86-
- CUDA accelerated H264/H265 encoding and decoding
87-
- Nvidia Video Codec SDK (check out [this](https://gist.github.com/corenel/a615b6f7eb5b5425aa49343a7b409200) to enable CUDA acc. H264/H265 enc/dec)
88-
- _Recommended for **AMD GPUs**_
96+
- Supported platforms: CUDA enabled NVIDIA GPU ([List of CUDA GPUs](https://developer.nvidia.com/cuda-gpus)) (tested on GTX1070, GTX1080Ti and RTX 2070)
97+
- Noticable features:
98+
- HW H264/H265 encoding and decoding
99+
- Bitrate control (CBR, VBR, CQP)
100+
- Installation process (not so tedious, but still):
101+
- Get your correct drivers, CUDA and preferably CUDNN ([Link](https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu))
102+
- Follow [this](https://gist.github.com/corenel/a615b6f7eb5b5425aa49343a7b409200) guide (mind here to **checkout the correct branch for your GStreamer version**, for me it was 1.16.2 instead of 1.14.0) and **read the comments**.
103+
- If you're having problems finding the plugins, check the installation paths of GStreamer plugins. It may be found in `/usr/lib/x86_64-linux-gnu/gstreamer-1.0/`, or in `/usr/local/lib/gstreamer-1.0/` or even in your local path if you don't have `sudo`. Truth is that i copipasta'd the files until it matched. There might be a more elegant way to do this.
104+
105+
- _**AMD GPUs**_
89106
- get a NVIDIA GPU (or feel free to contribute method)
90107
- not sponsored by NVIDIA, but by [them](https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstleyVEVO)
91-
- Build & install **OpenCV 4.x** (4.2 works good for me)
92-
- Mind that CUDA requires opencv-contrib modules
93-
- enable deprecated PKG_CONFIG files. Idk why OpenCV thinks they aren't needed anymore.
94-
- highly recommend **cmake-gui** (`sudo apt-get install cmake-qt-gui`); search and click the features you want to have enabled
108+
109+
# Building OpenCV
110+
- Build & install **OpenCV 4.x** (4.2 works good for me; ROS works with it)
111+
- Mind here that we need to change **a lot** of CMake flags, so I highly recommend **cmake-gui** (`sudo apt-get install cmake-qt-gui`); search and click the features you want to have enabled (even after your exec'd a usual `cmake -D` flag)
112+
- [Guide](https://medium.com/@sb.jaduniv/how-to-install-opencv-4-2-0-with-cuda-10-1-on-ubuntu-20-04-lts-focal-fossa-bdc034109df3) for building with CUDA support on Ubuntu 20.04 ([18.04 here](https://gist.github.com/raulqf/f42c718a658cddc16f9df07ecc627be7))
113+
- Mind that CUDA requires opencv-contrib modules (do not forget to check out the correct version here as well)
114+
- enable deprecated OPENCV_GENERATE_PKGCONFIG files. Idk why OpenCV thinks they aren't needed anymore.
95115
- or enable gstreamer 1.0 support with `-D WITH_GSTREAMER=ON`
96116

97-
## Tests
117+
# Tests
98118

99119
- Test if **GStreamer installation** was successful (You should see your webcam's image):
100120

@@ -118,7 +138,7 @@ $ gst-inspect-1.0 | grep nvenc
118138
nvenc: nvh264enc: NVENC H.264 Video Encoder
119139
```
120140

121-
## Usage
141+
# Usage
122142

123143
- [gst_device_to_shm](gst_device_to_shm.py) grabs the `VideoCapture(0)` and puts the raw image in a shared memory. Mind here to define your own webcam properties.
124144
- [gst_shm_to_app](gst_shm_to_app.py) grabs the shared memory frame from [gst_device_to_shm](gst_device_to_shm.py) and pipes it to a VideoCapture.
@@ -127,12 +147,15 @@ nvenc: nvh264enc: NVENC H.264 Video Encoder
127147
- [gst_intel_device_to_app_to_file](gst_intel_device_to_app_to_file.py) grabs the `v4l2src /dev/video0` (usually webcam) to OpenCV format and writes it as an h264 encoded file.
128148
- [gst_intel_device_to_app_to_rtp](gst_intel_device_to_app_to_rtp.py) grabs the `v4l2src /dev/video0` (usually webcam) to OpenCV format and writes it as an h264 encoded rtp stream. Use the provided `*.sdp` files for VLC viewer.
129149
- [gst_shm_to_rtp](gst_shm_to_rtp.py) grabs the shared memory frame from [gst_device_to_shm](gst_device_to_shm.py) ,encodes the frame and streams it to `rtp://localhost:5000`.
150+
- [gst_nvidia_device_to_app_to_file] (coming_soon™)
151+
- [gst_nvidia_device_to_app_to_rtp] (coming_soon™)
152+
- [gst_raspberrypi_device_to_app_to_file] (coming_soon™)
130153

131-
## Further informations
154+
# Further informations
132155

133156
Inspired by https://github.com/tik0/mat2gstreamer
134157

135-
## Disclaimer
158+
# Disclaimer
136159

137160
- Use at your own risk
138161
- It works on my machine

0 commit comments

Comments
 (0)