使用Cerbero编译gstreamer
Cerbero是一个跨平台的开源项目构建聚合工具,可以为不同的平台、架构和发行版构建和创建本地包。它支持本地编译和交叉编译,可以在MacOS、Linux和Windows上运行。
下载cerbero
git clone https://gitlab.freedesktop.org/gstreamer/cerbero
配置env
执行cerbero-uninstalled可能碰到的错误
$ ./cerbero-uninstalled
Python >= 3.8 detected and the 'distro' python package was not found.
$ pip3 install distro
运行cerbero-uninstalled,可能需要手动安装libssl-dev依赖
sudo aptitude install libssl-dev
bootstrap命令使用软件包管理器安装构建系统的缺失部分,并且在为Windows/MinGW或Android构建时下载必要的工具链。
cd cerbero
./cerbero-uninstalled bootstrap
编译gstreamer
checkout比较新的tag编译,cerbero需要python>=3.6
git checkout 1.19.3
./cerbero-uninstalled package gstreamer-1.0
Build tools install prefix will be /home/hui/disk4t/codes/gstplayer/gstreamer/gstreamer-cerbero/build/build-tools
Install prefix will be /home/hui/disk4t/codes/gstplayer/gstreamer/gstreamer-cerbero/build/dist/linux_x86_64
Building the following recipes: libffi zlib glib bash-completion libunwind gobject-introspection gstreamer-1.0 libogg libpng pixman expat bzip2 freetype fontconfig cairo fribidi harfbuzz pango libvorbis libtheora orc opus graphene libjpeg-turbo cdparanoia gst-plugins-base-1.0 gst-shell speex tiff gdk-pixbuf libxml2 glib-networking libpsl sqlite3 libsoup mpg123 lame wavpack flac taglib libvpx libdv gst-plugins-good-1.0 libass libkate openh264 librtmp libsrtp libdca libdvdread libdvdnav libnice soundtouch vo-aacenc libcroco librsvg openjpeg spandsp webrtc-audio-processing sbc ladspa srt zbar gst-plugins-bad-1.0 a52dec opencore-amr x264 gst-plugins-ugly-1.0 json-glib gst-rtsp-server-1.0 ffmpeg gst-libav-1.0 gst-devtools-1.0 gst-editing-services-1.0
交叉编译an
# Bootstrap for Android Universal on Linux
$ ./cerbero-uninstalled -c config/cross-android-universal.cbc bootstrap
# Build everything and package for Android Universal
$ ./cerbero-uninstalled -c config/cross-android-universal.cbc package gstreamer-1.0
编译完成后生成gstreamer-1.0-android-universal-1.19.3.tar.xz,和上面下载的一样。
启用可选功能
list-variants可以列出支持的选项
$ ./cerbero-uninstalled --list-variants
Available boolean variants are: alsa, cdparanoia, debug, gi, intelmsdk, optimization, pulse, python, qt5, rpi, testspackage, unwind, uwp, v4l2, vaapi, visualstudio, werror, x11
Available mapping variants are: vscrt
指定variantname
/cerbero-uninstalled -v variantname [-c ...] package gstreamer-1.0
使用编译后的环境
配置环境变量
$ export GST_PLUGIN_PATH=/home/hui/data/gstreamer-cerbero/build/dist/linux_x86_64/lib
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hui/data/gstreamer-cerbero/build/dist/linux_x86_64/lib
$ export GST_PLUGIN_SCANNER=/home/hui/data/gstreamer-cerbero/build/dist/linux_x86_64/libexec/gstreamer-1.0
配置环境变量后,执行gst-launch或者gst-inspect就可以注册GST_PLUGIN_PATH目录下的插件
$ cd build/dist/linux_x86_64/bin
$ GST_DEBUG=GST_REGISTRY:5 ./gst-inspect-1.0 avdec_h264
从log中可以方便的找到registry文件
GST_REGISTRY gstregistry.c:1755:ensure_current_registry: reading registry cache: /home/hui/.cache/gstreamer-1.0/registry.x86_64.bin
播放文件
./gst-launch-1.0 playbin uri=file:///home/hui/media/