跳转至

GStreamer 源码 Meson 编译 1.20

版本与环境介绍

GStreamer version : 1.20

Ubuntu : 18.04

1. 下载 GStreamer 源码

git clone -b 1.20 https://gitlab.freedesktop.org/gstreamer/gstreamer.git

这里下载1.20版本

pub@ubuntu64:/mnt/work/zheng/gstreamer$ git clone  Cloning into •gstreamer•  remote: Enumerating obj ects: 851416, done .  remote: Counting objects: 100% (73/73), done.  remote: Compressing objects: 100% (55/55), done.  -b  1.26 https : //gitlab.freedesktop.org/gstreamer/gstreamer.git  remote: Total 851416 (delta 39), reused 32 (delta 18), pack-reused 851343  Receiving objects: 100% (851416/851416), 199.48 MiB | 695.€€ KiB/s, done.  Resolving deltas: 100% (668387/668387), done.  Checking out files: 100% (9964/9964), done.  pub@ubuntu64:/mnt/wo rk/zheng/gs t reame r$

2. 配置

不指定option的情况下,执行meson,会按默认的规则编译,是不带libav,x264的。

cd gstreamer
meson build

meson configure | grep 264可以查看是否编译进去;

 pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ meson configure | grep 264
 libopenh264          auto               [enabled, disabled, auto]    libopenh264
 libx264            auto               [enabled, disabled, auto]    libx264
 openh264            auto               [enabled, disabled, auto]    H.264 video codec plugin
 uvch264            auto               [enabled, disabled, auto]    UVC compliant H.264 camera source plugin
 x264              auto               [enabled, disabled, auto]    H.264 video encoder plugin based on libx264 (GPL - only built if
 x264_libraries                                          Colon separated list of additional x264 library paths, e.g. for

Subproject openh264:

image-20240802162328619

指定reconfigure

meson --reconfigure build

指定安装目录

meson --reconfigure build --prefix=/mnt/work/zheng/gstreamer/gstreamer/install

3. 编译

ninja -j36 -C build

4. 安装

安装

meson install -C build

5. 虚拟环境测试

pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ cd build/
pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$ ls
build.ninja compile_commands.json GstDocumentedSubprojects GstPluginsPath.json meson-info meson-logs meson-private meson-uninstalled subprojects tests
pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$ ninja devenv
[0/1] Running external command devenv (wrapped by meson to set env)
[gst-1.20] pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$

pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ cd build/  pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/bui1d$ Is  build . ninja compile _ commands . j son GS tDocumentedSubproj ects Gstpluginspath . json  pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$ ninja devenv  [0/1] Running external command devenv (wrapped by meson to set env)  [gst-1.20] pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$  [gst-1.20] pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$ gst-  meson-info  meson -

[gst-l .20] pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer/build$  [gst-1.2a] gst-inspect-l.e I grep 264  libav:  avdec h264. libav H.  264 / AVC / MPEG-4 AVC / MPEG-4 part 10 decoder  libav:  avmux_ipod: libav ipod H. 264 MP4 (MPEG-4 Part 14) muxer  rtp: rtph264depay: RTP H264 depayloader  rtp: rtph264pay: RTP H264  payloader  typefindfunctions: video/x-h264•  h264, x264, 264  videoparsersbad:  h264parse: H. 264  parser

6. 遇到问题

6.1 Python 版本切换

# 查看有哪些版本
ls /usr/bin/python*
# 设定:
alias python=/usr/bin/python3.8
alias python3=/usr/bin/python3.8

pub@ubuntu64:/mnt/work/zheng/gstreamer/cerbero$ python -V  python 2.7.17  pub@ubuntu64:/mnt/work/zheng/gstreamer/cerbero$ Is Jus r/bin/python*  'us r/bin/python 'us r/bin/python2 /us r/bin/python2.7 Jus r/bin/python3 Jus r/bin/python3.6  pub@ubuntu64:/mnt/wo rk/zheng/gs t reame r/ ce rbe ro$  pub@ubuntu64:/mnt/work/zheng/gstreamer/cerbero$ alias python=/us r/bin/python3  pub@ubuntu64:/mnt/work/zheng/gstreamer/cerbero$ python -V  python 3.6.9  pub@ubuntu64:/mnt/wo rk/zheng/ gst reame rice rbe ro$  Jus r/bin/python3.6m  Jus r/bin/python3m

再更新为3.7

pub@ubuntu64:/mnt/wo rk/zheng/gs t reame r/gs t reame r$  pub@ubuntu64:/mnt/wo rk/zheng/gs t reame r/gs t reame r$  pub@ubuntu64:/mnt/wo rk/zheng/gs t reame r/gs t reame r$  pub@ubuntu64:/mnt/wo rk/zheng/gs t reame rigs t reame r$  python 3.7.5  alias python=/us r/bin/python3.7  python -  - ve rs Ion

6.2 Meson 版本

sudo apt-get install meson

版本需要0.60以上,发现版本不对

pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ meson --version
0.45.1
pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ pip3 install --user meson
Collecting meson
Downloading https://files.pythonhosted.org/packages/95/0a/c961c525cd1b2914fa9cc85692f25a44012759ca1f25a96bda3fec74aa09/meson-0.61.4-py3-none-any.whl (863kB)
  100% |████████████████████████████████| 870kB 1.7MB/s
Installing collected packages: meson
Successfully installed meson-0.61.4
pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ meson --version
0.45.1

发现版本还是不对;

[原因: 继续搜索发现pip3会将软件安装到/home/user/.local/bin 而系统默认是使用/usr/bin/meson]

设置环境变量

pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ export PATH=~/.local/bin:$PATH
pub@ubuntu64:/mnt/work/zheng/gstreamer/gstreamer$ meson --version
0.61.4

正常

部分需要修改root 用户相关的版本

$ git clone -b 1.20 https://github.com/GStreamer/gst-rtsp-server.git
meson --reconfigure build --prefix=/home/mhpub/gstreamer/gst-rtsp-server/build/out

网络相关问题,代理

git config --global user.name "hywelstar"
git config --global user.email "[email protected]"
git config --list

export http_proxy=http://192.168.5.104:10809
export https_proxy=https://192.168.5.104:10809

git config --global http.proxy http://192.168.5.104:10809
git config --global https.proxy https://192.168.5.104:10809

############取消代理############
git config --global --unset http.proxy
git config --global --unset https.proxy

unset http_proxy
unset https_proxy