跳转至

GStreamer 源码 Meson 编译 1.24

版本与环境介绍

GStreamer version : 1.24

Ubuntu : 22.04

1. 下载 GStreamer 源码

$ cat /proc/version
Linux version 6.5.0-44-generic (buildd@lcy02-amd64-103) (x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jun 18 14:36:16 UTC 2
 git clone -b 1.24 https://gitlab.freedesktop.org/gstreamer/gstreamer.git

这里下载1.24版本

image-20240819152636412

2. 依赖相关包安装

python3 >= 3.8
ninja >=
meson >=1.1

2.1 部分包安装

为了解决后续配置编译问题还需要安装【不然出现错误】:

sudo apt install flex bison

可选依赖包

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

2.2 安装 Meson 和 Ninja

sudo apt install python3-pip

更新meson 版本

pip3 install meson==1.3.1 --break-system-packages

image-20240819162104444

3. 配置编译安装

3.1 配置编译

# 配置
meson setup builddir
# 推荐!!!!配置安装指定路径
mkdir _install
meson setup --prefix=/home/hywelstar/Develop/gstreamer/_install builddir

# 编译
meson compile -C builddir

假如需要安装指定目录可以选择一下方式:

# ===============以下可选择==============
# 更换安装目录方法:
# 首次配置的话采用
meson setup --prefix=/home/hywelstar/Develop/gstreamer/_install builddir
# 中途更改安装到指定路径
meson setup  builddir --reconfigure  --prefix=/home/hywelstar/Develop/gstreamer/_install
# =====================================

配置完成:

image-20240820091519247

编译

meson compile -C builddir

image-20240820110745980

3.2 安装

meson install -C builddir

image-20240820140546129

看到下图表示安装成功

4. 环境测试

运行gst-env.py 将带你进入刚刚编译的那个环境

./gst-env.py

## 本工程使用这个
./gst-env.py --builddir builddir

## 或者这个代替
ninja devenv

image-20240821135744726

测试命令:

$ gst-inspect-1.0 --version
gst-inspect-1.0 version 1.24.6
GStreamer 1.24.6 (GIT)

image-20240820145900777

图像测试【如果出现错误,请跳转配置参数章节】:

GST_DEBUG=3 gst-launch-1.0 videotestsrc ! autovideosink

image-20240822091653656

5. 问题解决

5.0 网络问题代理

git config --global user.name "hywelstar"
git config --global user.email "hywelstar@126.com"
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

5.1 ERROR: Meson version is 0.61.2 but project requires >= 1.1

The Meson build system Version: 0.61.2 Source dir: /home/hywelstar/Develop/gstreamer Build dir: /home/hywelstar/Develop/gstreamer/builddir Build type: native build

meson.build:1:0: ERROR: Meson version is 0.61.2 but project requires >= 1.1

image-20240828075328698

解决办法:

$ meson --version
0.45.1
$ pip3 install meson==1.3.1

image-20240828091627256

其他可能报错 error: externally-managed-environment

image-20240819163056999

解决:

pip3 install meson==1.3.1 --break-system-packages

meson 版本过低,强制安装meson 版本。

5.3 'flex win_flex' not found

ERROR: Program 'flex win_flex' not found or not executable

image-20240819162617739

解决办法:

$ sudo apt install flex

5.4 'bison win_bison' not found or not executable

image-20240819163152673

$ sudo apt install bison

5.5 Failed to find a usable video sink

image-20240821143535339

5.6 ERROR: Program 'bison win_bison' not found or not executable

gstreamer| Program bison win_bison found: NO

subprojects/gstreamer/gst/parse/meson.build:34:8: ERROR: Program 'bison win_bison' not found or not executable

image-20240828092718931

sudo apt install bison