前序参考:


开发环境

基于ubuntu18.04.6的gstreamer开发环境搭建_linux

下载压缩包,我们使用1.21.1版本的插件和gstearmer核心软件包。

基于ubuntu18.04.6的gstreamer开发环境搭建_linux_02

 安装依赖

$ sudo apt-get install build-essential dpkg-dev flex bison autotools-dev automake liborc-dev autopoint libtool gtk-doc-tools python3-pip bison flex ninja-build
$ sudo pip3 install meson
$ sudo snap install valgrind --classic
$ sudo apt install valgrind
$ sudo apt-get install libgirepository1.0-dev libcap-dev libgtk-3-dev libunwind-dev clzip gobject-introspection libdw-dev

GSL和GMP库需要从源码开始编译安装,按照./configure && make && make install 三部操作即可安装。

基于ubuntu18.04.6的gstreamer开发环境搭建_git_03

编译gstreamer核心包

解压gstreamer-1.21.1.tar.xz,执行menson build命令编译安装gstreamer-1.21.1核心包,出现如下错误,原因是meson版本低于要求的版本,我们升级meson版本满足要求:

基于ubuntu18.04.6的gstreamer开发环境搭建_ubuntu_04

方法是升级python到3.8

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt install python3.8
$ python3.8 -m pip install --upgrade pip
$ /home/czl/.local/bin/pip3 install meson==0.63

为了避免和环境冲突,我们输入新安装的meson全路径调用

/home/czl/.local/bin/meson build

遇到错误,需要升级glib.

基于ubuntu18.04.6的gstreamer开发环境搭建_运维_05

https://gitlab.gnome.org/GNOME/glib/-/tags

如下命令序列安装glib.

$ meson build
$ ninja -C build
$ ninja -C build install

之后再次执行/home/czl/.local/bin/meson build,成功

基于ubuntu18.04.6的gstreamer开发环境搭建_linux_06

 之后执行如下命令编译完成gstreamer核心包

$ ninja -C build install
$ sudo ninja -C build install

基于ubuntu18.04.6的gstreamer开发环境搭建_python_07

 其他几个包或多或少都需要安装新的依赖,索性一起安装了:

$ sudo apt-get install libxv-dev libasound2-dev libtheora-dev libogg-dev libvorbis-dev
$ sudo apt-get install libbz2-dev libv4l-dev libvpx-dev libjack-jackd2-dev libsoup2.4-dev libpulse-dev
$ sudo apt-get install faad libfaad-dev libfaac-dev
$ sudo apt-get install libx264-dev libmad0-dev
$ sudo apt-get install yasm cmake

之后安装的几个PLUGIN,包括gst-plugins-base-1.21.1,gst-plugins-good-1.21.1,gst-plugins-bad-1.21.1,gst-plugins-ugly-1.21.1,连同gstreamer核心包一起,一共安装了5个,配置和编译方法都是一样的:

$ /home/czl/.local/bin/meson build
$ ninja -C build
$ sudo ninja -C build install

还剩下三个包没有安装,包括gst-libav-1.21.1.tar.xz,gst-omx-1.21.1.tar.xz,gstreamer-vaapi-1.21.1.tar.xz:

基于ubuntu18.04.6的gstreamer开发环境搭建_linux_08

`不过并不影响我们搭建一个简单的从事管道进行测试,输出显示管道搭建成功,而GST版本确实也是我们编译安装的版本。

gst-launch-1.0 -v fakesrc num_buffers=5 ! fakesink

基于ubuntu18.04.6的gstreamer开发环境搭建_git_09

接下来安装其余的部分。

configure gst-libav-1.21.1.tar.xz

基于ubuntu18.04.6的gstreamer开发环境搭建_linux_10

配置失败,是因为gst-libav之是一个符合GST插件标准的壳,真正完成编码,解码的是ffmpeg,上图的警告很明显,告诉我们需要libavfilter找不到,libavfilter是ffmpeg专门用来进行容器解封装的组件,所以下一步,我们首先安装ffmpeg.


下载ffmpeg解压&configuration:

$ /configure --target-os=linux --arch=x86_64 --disable-doc --enable-libx264 --enable-libmp3lame --enable-libopus --enable-debug=3 --extra-cflags="" --extra-ldflags="" --enable-gpl
$ make && sudo make install

基于ubuntu18.04.6的gstreamer开发环境搭建_python_11

基于ubuntu18.04.6的gstreamer开发环境搭建_运维_12

test ffplay:

基于ubuntu18.04.6的gstreamer开发环境搭建_python_13

success of installing gst-libav plugin.

基于ubuntu18.04.6的gstreamer开发环境搭建_运维_14

Test gstreamer with pipeline:

gst-play-1.0 webwxgetvideo.mp4

基于ubuntu18.04.6的gstreamer开发环境搭建_ubuntu_15

Test Fine.

install gstreamer-vaapi-1.21.1

基于ubuntu18.04.6的gstreamer开发环境搭建_python_16

lack of libva, so should install libva first.


$ git clone https://github.com/intel/libva.git
$ git reset --hard 2.16.0

after this, reconfig the vaapi plugin compile process:

/home/czl/.local/bin/meson build

基于ubuntu18.04.6的gstreamer开发环境搭建_python_17

基于ubuntu18.04.6的gstreamer开发环境搭建_git_18

VAAPI plugin info:

gst-inspect-1.0 ./build/gst/vaapi/libgstvaapi.so

基于ubuntu18.04.6的gstreamer开发环境搭建_ubuntu_19

how to create your own plugin?

1.get the gst-template project

git clone git://anongit.freedesktop.org/gstreamer/gst-template.git

基于ubuntu18.04.6的gstreamer开发环境搭建_git_20

 2.step into gst-template/gst-plugin/src, execute

./../tools/make_element zlcao

 zlcao is the name of the plugin.

基于ubuntu18.04.6的gstreamer开发环境搭建_ubuntu_21

3.back to top dir gst-template,execute

$ meson build
$ ninja -C build

基于ubuntu18.04.6的gstreamer开发环境搭建_运维_22

 the zlcao plugin was generated:

基于ubuntu18.04.6的gstreamer开发环境搭建_git_23

 gst inspect:

gst-inspect-1.0 ./build/gst-plugin/libgstzlcao.so

基于ubuntu18.04.6的gstreamer开发环境搭建_运维_24

gst inspect zlcao plugin:

copy the new generated libgstzlcao.so to gst recongnized directory  

/home/czl/.local/share/gstreamer-1.0/plugins/

cp ./build/gst-plugin/libgstzlcao.so /home/czl/.local/share/gstreamer-1.0/plugins/

then inspect the plugin "zlcao" with gst-inspect tools:

gst-inspect-1.0 zlcao

基于ubuntu18.04.6的gstreamer开发环境搭建_ubuntu_25


结束