Gstreamer ubuntu源码安装
Ubuntu直接使用apt-get安装gstreamer版本比较老,需要源码编译安装.
一、官网版本
官网: https://gstreamer.freedesktop.org/
源码: https://gstreamer.freedesktop.org/src/
目前官网最新的版本是 1.20.1
二、 源码下载
gst-plugins-base-1.20.1.tar.xz
gst-plugins-good-1.20.1.tar.xz
gst-plugins-ugly-1.20.1.tar.xz
也可以根据自己需要下载其他例如gst-ffmpeg,gst-omx等安装包.
三、编译安装
编译安装之前最好先卸载原有的版本,可以使用命令 sudo apt-get remove gstreamer*
3.1 安装Meson
git clone https://github.com/mesonbuild/meson.git
cd meson
git checkout 0.59
python3 setup.py install --root=temp
sudo cp -rf temp/* /
meson --version
3.1 meson脚本编译
GStreamer源码编译安装脚本化_编码笔记的博客-CSDN博客_gstreamer源码编译 提供了一键脚本编译,这里默认是1.20.1版本
#!/bin/bash shellname=$(basename $0) ### configure gst_version # orc_version="master" # gst_version="master" gst_version="1.20.1" orc_version="orc-0.4.32" gst_src="${HOME}/gst" # Number of threads = cpu core - 1 core_num=$(grep 'core id' /proc/cpuinfo |wc -l) thread=$(expr $core_num - 1) mkdir -p ${gst_src} rm_dir() { for i in "$@" do if [ "${i}" = "" ];then continue fi if [ -d ${i} ];then rm -rf ${i} fi done } check_status() { code=$1 if [ "X${code}" != "X0" ];then echo "Error Code=${code}" exit $code fi } check_version() { v=$1 if [ "X" = "X${v}" ];then return 0 else branch_list=$(git branch) check_status $? res=$(echo $branch_list |grep -E "^\* ${v}$") if [ "$res" = "" ];then git checkout $v check_status $? fi fi } clone_gst_pkg() { # reference https://gitlab.freedesktop.org/gstreamer pkg_name="$1" version="$2" if [ "" = "${pkg_name}" ];then return 1 fi cd ${gst_src} echo -e "\n\n\n------------------------ clone ${pkg_name} -----------------" if [ -d ${gst_src}/${pkg_name} ];then cd ${gst_src}/${pkg_name} git branch if [ $? -ne 0 ];then cd ${gst_src} rm_dir ${gst_src}/${pkg_name} git clone https://gitlab.freedesktop.org/gstreamer/${pkg_name}.git check_status $? fi else git clone https://gitlab.freedesktop.org/gstreamer/${pkg_name}.git check_status $? fi if [ "${version}" = "" ];then return 0 fi # Switch branches or restore working tree files cd ${gst_src}/${pkg_name} git pull # git checkout ${version} # check_status $? check_version ${version} } install_meson() { cur_dir=$(pwd) meson_version="$1" if [ "${meson_version}" = "" ];then meson_version="0.57" fi # skip install if meson version is 0.5x install_flag=$(meson --version |grep -E "^0\.5+") if [ "${install_flag}" != "" ];then return fi meson_src=~/meson cd ~ echo -e "\n\n\n------------------------ install meson ---------------------" # download source code if [ -d ${meson_src} ];then cd ${meson_src} git checkout ${meson_version} if [ "X${?}" != "X0" ];then cd - rm_dir ${meson_src} git clone https://github.com/mesonbuild/meson.git check_status $? cd ${meson_src} git checkout ${meson_version} fi else git clone https://github.com/mesonbuild/meson.git check_status $? cd ${meson_src} git checkout ${meson_version} fi sudo apt install python3-pip -y # python3 -m pip install meson # python3 setup.py install python3 setup.py install --root=dest check_status $? sudo cp -rv dest/* / check_status $? echo -e "\n\n\n------------------------ finish meson ----------------------" cd ${cur_dir} } install_ninja() { cur_dir=$(pwd) ninja_version="$1" if [ "${ninja_version}" = "" ];then ninja_version="release" fi # ninja --version # if [ $? -eq 0 ];then # return # fi install_flag=$(ninja --version |grep -E "^${ninja_version}") if [ "${install_flag}" != "" ];then return fi sudo apt install re2c -y ninja_src=~/ninja cd ~ rm -rf ~/ninja # sudo python3 -m pip install ninja echo -e "\n\n\n------------------------ install ninja ---------------------" if [ -d ${ninja_src} ];then cd ${ninja_src} git checkout v${ninja_version} if [ "X${?}" != "X0" ];then cd - rm_dir ${ninja_src} git clone https://github.com/ninja-build/ninja.git check_status $? cd ${ninja_src} git checkout v${ninja_version} fi else git clone https://github.com/ninja-build/ninja.git check_status $? cd ${ninja_src} git checkout v${ninja_version} fi ./configure.py --bootstrap check_status $? sudo cp ninja /usr/bin/ echo -e "\n\n\n------------------------ finish ninja ----------------------" cd ${cur_dir} } # compile and install current directory source code install_obj() { if [ -f ./meson.build ];then install_meson install_ninja "1.8.2" # meson build -Dprefix=/usr && ninja -C build && sudo ninja -C build install meson build check_status $? ninja -C build check_status $? sudo ninja -C build install check_status $? elif [ -f ./autogen.sh ];then ./autogen.sh if [ $? -eq 0 ];then make -j${thread} && sudo make install if [ $? -eq 0 ];then return 0 else ./configure check_status $? fi else ./configure check_status $? fi make -j${thread} && sudo make install check_status $? elif [ -f ./configure ];then ./configure check_status $? make -j${thread} && sudo make install check_status $? else pwd echo "[error] cannot found meson.build or autogen.sh" exit 1 fi } build_and_install_pkg() { for i in "$@" do if [ "${i}" = "" ];then continue fi if [ "${i}" = "orc" ];then clone_gst_pkg "$i" "${orc_version}" install_obj continue fi clone_gst_pkg "$i" "${gst_version}" install_obj done } uninstall_pkg() { # reverse pkg list for i in $(seq $# |tac ) # for i in "$@" do pkg_name=$(eval echo '$'"$i") if [ "${pkg_name}" = "" ];then continue fi pkg_dir="${gst_src}/${pkg_name}" if [ ! -d ${pkg_dir} ];then continue fi cd ${pkg_dir} echo -e "\n\n\n------------------------ uninstall ${pkg_name} ---------" if [ -f ./meson.build ];then sudo ninja -C build uninstall sudo ninja -C build clean elif [ -f ./autogen.sh -o -f ./configure ];then sudo make uninstall make distclean else pwd echo "[error] cannot found meson.build or autogen.sh" fi done } help_msg() { msg=" Usage: ./${shellname} [options] options: install - download source code and install gstreamer and gst plugins uninstall - uninstall gstreamer and gst plugins e.g. ./${shellname} install ./${shellname} uninstall " echo "${msg}" } # main if [ $# -eq 1 ];then exe_type=$(echo "$1" | tr 'A-Z' 'a-z' ) if [ "${exe_type}" != "install" -a "${exe_type}" != "uninstall" ];then echo "[error] unknow option: $1" help_msg exit 1; fi echo "${exe_type} gstreamer[y/n]:" read choose; echo "Your Choice:${choose}" choose=$(echo "${choose}" | tr 'A-Z' 'a-z' ) if [ "X${choose}" != "Xy" ];then echo "Cancel ${exe_type}" exit 1; fi $(sudo ls) sudo apt install -y git autoconf autopoint libtool bison flex gtk-doc-tools libglib2.0-dev libssl-dev libva-dev libgtk2.0-dev # sudo apt install meson if [ "Xinstall" = "X${exe_type}" ];then echo "install....." # install_gst build_and_install_pkg "gstreamer" "orc" "gst-plugins-base" "gst-plugins-good" "gst-plugins-ugly" "gst-plugins-bad" "gstreamer-vaapi" elif [ "Xuninstall" = "X${exe_type}" ];then echo "uninstall....." # uninstall_gst uninstall_pkg "gstreamer" "orc" "gst-plugins-base" "gst-plugins-good" "gst-plugins-ugly" "gst-plugins-bad" "gstreamer-vaapi" fi else help_msg fi
2022-04-22
本文来自博客园,作者:追随技术,转载请注明原文链接:https://www.cnblogs.com/545235abc/p/16179651.html
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 我与微信审核的“相爱相杀”看个人小程序副业
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~