在 Ubuntu 22.04 上编译 VideoLan 播放器
后知后觉 暂无评论

在 Ubuntu 22.04 上编译 VLC 3.0.18,仓库内版本为 3.0.16。

编译

首先克隆 VLC 源码

git clone https://code.videolan.org/videolan/vlc.git
cd vlc/
git checkout 3.0.18

安装构建基础依赖

sudo apt install -y flex build-essential bison autoconf libtool pkgconf git
sudo apt install -y liba52-0.7.4-dev libalsa-ocaml-dev libavcodec-dev libavformat-dev libdbus-1-dev liblua5.2-dev libqt5svg5-dev libswscale-dev libxcb-composite0-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xv0-dev libxcb-xkb-dev lua5.2 qtbase5-dev qtdeclarative5-dev qtquickcontrols2-5-dev

预编译

./bootstrap
./configure

如果没有特殊功能需求的话可以直接进行构建

make -j8

编译完成后工程目录中 ./vlc 的软链接即为主程序。

预览图

补充

在预构建时其中会看到大量警告信息,有一些可选功能依赖于其他组件,不安装依然可以构建,下面的内容可以根据需求进行补充:

sudo apt install libass-dev libdbus-1-dev libsystemd-dev libarchive-dev libgtk-3-dev \
 libraw1394-dev libavc1394-dev libdc1394-dev libdvdread-dev libdvdnav-dev \
 libbluray-dev libssh2-1-dev libnfs-dev libcddb2-dev libvncserver-dev \
 libgme-dev libsidplay2-dev libogg-dev libshout-ocaml-dev libmodplug-dev \
 libshine-dev libmpg123-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libxkbcommon-x11-dev \
 libxcb-keysyms1-dev libxcb-damage0-dev libva-dev libva-drm2 libva-x11-2 \
 libva-wayland2 libpostproc-dev libaom-dev libtwolame-dev libdca-dev \
 libflac-dev libmpeg2-4-dev libspeexdsp-dev libopus-dev libspatialaudio-dev \
 libx265-dev libmfx-dev libfluidsynth-dev libaribb24-dev libkate-dev \
 librsvg2-dev libcaca-dev libjack-dev libsamplerate0-dev libsoxr-dev \
 libresid-builder-dev libebur128-dev libchromaprint-dev libprotobuf-dev protobuf-compiler \
 libavahi-client-dev libprojectm-dev libudev-dev libmtp-dev libupnp-dev \
 libxml2-dev libtaglib-ocaml-dev libsecret-1-dev libnotify-dev libqt5x11extras5-dev \
 libqt5waylandclient5-dev libzvbi-dev libmatroska-dev libdav1d-dev libsdl-image1.2-dev 
补充:使用上面的命令可以解决其中的大部分依赖,还有少部分依赖为仓库缺失或者版本不匹配,需要手动处理。在 Ubuntu 20.04 中 LIBSRT 包为 libsrt-dev 在 Ubuntu 22.04 中为 libsrt-openssl-dev,编译时注意处理。

LIVE555

checking for LIVE555... no
configure: WARNING: No package 'live555' found.
checking for live555 version 1324598400 or later... no
configure: WARNING: live555 is missing or its installed version is too old:
Version 2011.12.23 or later is required to proceed.
You can get an updated one from http://www.live555.com/liveMedia .

live555 是播放直播流需要的组件,如果不需要可以忽略,此包未再官方源中提供,需要手动编译安装。

在 Ubuntu 20.04 中可以直接安装 liblivemedia-dev,在 Ubuntu 22.04 中此包被移除,需要手动下载安装

mkdir debs
cd debs/
wget http://archive.ubuntu.com/ubuntu/pool/universe/libl/liblivemedia/liblivemedia-dev_2020.01.19-1build1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/libl/liblivemedia/liblivemedia77_2020.01.19-1build1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/libl/liblivemedia/libbasicusageenvironment1_2020.01.19-1build1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/libl/liblivemedia/libgroupsock8_2020.01.19-1build1_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/libl/liblivemedia/libusageenvironment3_2020.01.19-1build1_amd64.deb
sudo apt install ./*.deb

GME

checking for GME... no
configure: WARNING: Library libgme needed for gme was not found

GME 组件官网:game-music-emu

tar xf game-music-emu-0.6.3.tar.gz
cd game-music-emu-0.6.3
mkdir build
cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr/local
make
sudo make install

SMB2

checking for SMB2... no
configure: WARNING: Library libsmb2 >= 3.0.0 needed for smb2 was not found

SMB2 组件官网:libsmb2

sudo apt install libkrb5-dev
git clone https://github.com/sahlberg/libsmb2.git
cd libsmb2/
./bootstrap
./configure
make
sudo make install

RNNOISE

checking for RNNOISE... no
configure: WARNING: Library rnnoise needed for rnnoise was not found

RNNOISE 组件官网:rnnoise

git clone https://github.com/xiph/rnnoise.git
cd rnnoise/
./autogen.sh
./configure
make
sudo make install

SCHROEDINGER

checking for SCHROEDINGER... no
configure: WARNING: Library schroedinger-1.0 >= 1.0.10 needed for schroedinger was not found

SCHROEDINGER 组件

wget http://launchpadlibrarian.net/92221360/libschroedinger-1.0-0_1.0.11-1_amd64.deb
wget http://launchpadlibrarian.net/92221361/libschroedinger-dev_1.0.11-1_amd64.deb
sudo apt install ./libschroedinger*.deb

DAVS2

checking for DAVS2... no
configure: WARNING: Library davs2 needed for davs2 was not found

DAVS2 组件官网:davs2

git clone https://github.com/pkuvcl/davs2.git
cd davs2/
cd build/linux/
./configure --enable-shared --enable-lto --enable-gprof --enable-strip --enable-pic
make
sudo make install
注意:这里的 configure 参数必须添加,否则会出现报错 /usr/bin/ld: libdavs2.a(mc-a2.o): relocation R_X86_64_32S against hidden symbol 'davs2_pw_00ff' can not be used when making a PIE object

FLUIDLITE

checking for FLUIDLITE... no
configure: WARNING: Library fluidlite needed for fluidlite was not found

FLUIDLITE 组件官网:FluidLite

git clone https://github.com/divideconcept/FluidLite.git
cd FluidLite/
mkdir build
cd build/
cmake -DENABLE_SF3=YES ../
make
sudo make install

RAV1E

checking for RAV1E... no
configure: WARNING: Library rav1e needed for rav1e was not found

RAV1E 组件官网:rav1e

sudo su - root
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
git clone https://github.com/xiph/rav1e.git
cd rav1e/
cargo install cargo-c
RUSTFLAGS="-C target-cpu=native" cargo cinstall --release
注意:因官方 Rust 编译器默认安装在用户目录下,因此在普通用户下安装编译 rav1e 无法安装至系统目录,所以上述操作需要切换到 root 用户下操作。

ARIBB25

checking for ARIBB25... no
configure: WARNING: Library aribb25 >= 0.2.6 needed for aribb25 was not found

ARIBB25 组件官网:aribb25

sudo apt install libpcsclite-dev
git clone https://code.videolan.org/videolan/aribb25.git
cd aribb25/
./bootstrap
./configure
make
sudo make install

ARIBCAPTION

checking for ARIBCAPTION... no
configure: WARNING: Library libaribcaption needed for aribcaption was not found

ARIBCAPTION 组件官网:libaribcaption

git clone https://github.com/xqq/libaribcaption.git
cd libaribcaption/
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j8
sudo cmake --install .

RIST

checking for RIST... no
configure: WARNING: Library librist needed for rist was not found

RIST 组件官网:librist

sudo apt install libcmocka-dev libmbedtls-dev
git clone https://code.videolan.org/rist/librist.git
cd librist/
mkdir build
cd build/
meson --default-library=static ..
ninja
sudo ninja install

MICRODNS

checking for MICRODNS... no
configure: WARNING: Library microdns >= 0.1.2 needed for microdns was not found

MICRODNS 组件官网:libmicrodns

git clone https://github.com/videolabs/libmicrodns.git
cd libmicrodns/
mkdir build
cd build/
meson ..
ninja
sudo ninja install

XEXT

checking for XEXT... yes
configure: WARNING: Skins2 interface disabled due to missing dependencies.

XEXT 依赖说明:#3821

sudo apt install libxpm-dev libxext-dev libxinerama-dev libfreetype-dev

MEDIALIBRARY

checking for MEDIALIBRARY... no
configure: WARNING: Library medialibrary >= 0.12.0 needed for medialibrary was not found

MEDIALIBRARY 组件官网:medialibrary

注意:这个软件在 Debian / Ubuntu 仓库的版本都很低(<= 0.6.0),所以不能使用仓库进行安装。

编译需要 sqlite3, libvlc, libjpeg, libvlcpp, libxxhash, benchmark 依赖

sqlite

sudo apt install libvlc-dev
wget https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz
tar xf sqlite-autoconf-3400100.tar.gz
cd sqlite-autoconf-3400100/
./configure
make
sudo make install

libvlcpp

git clone https://code.videolan.org/videolan/libvlcpp.git
cd libvlcpp/
./bootstrap
./configure
sudo make install

libxxhash-dev

sudo apt install libxxhash-dev
cd medialibrary-0.12.3/
mkdir build
cd build/
meson setup --wipe ..
ninja -j8

benchmark

git clone https://github.com/google/benchmark.git
cd benchmark/
cmake -E make_directory "build"
cmake -E chdir "build" cmake -DBENCHMARK_DOWNLOAD_DEPENDENCIES=on -DCMAKE_BUILD_TYPE=Release ../
cmake -DCMAKE_BUILD_TYPE=Release -S . -B "build"
cmake --build "build" --config Release
sudo cmake --build "build" --config Release --target install

编译时需要安装依赖 rapidjson-dev 否则会有报错

[122/155] Compiling C++ object test/samples/samples.p/main.cpp.o
FAILED: test/samples/samples.p/main.cpp.o
c++ -Itest/samples/samples.p -Itest/samples -I../test/samples -I. -I.. -Iinclude -I../include -Isrc -I../src -Itest -I../test -I/usr/local/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c++14 -O0 -g -DHAVE_CONFIG_H=1 -DXXHASH_DYNAMIC_DISPATCH=1 -pthread '-DSRC_DIR="/home/kane/Libs/medialibrary-0.12.3"' -MD -MQ test/samples/samples.p/main.cpp.o -MF test/samples/samples.p/main.cpp.o.d -o test/samples/samples.p/main.cpp.o -c ../test/samples/main.cpp
In file included from ../test/samples/main.cpp:27:
../test/samples/Tester.h:28:10: fatal error: rapidjson/document.h: No such file or directory
   28 | #include <rapidjson/document.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
[129/155] Compiling C++ object test/un...eo_track_tests.p/VideoTrackTests.cpp.o
ninja: build stopped: subcommand failed.

OPENCV

checking for OPENCV... no
configure: WARNING: Library opencv > 2.0 needed for opencv was not found

OPENCV 组件官网:opencv

注意:目前 VLC 不支持高版本的 opencv (4.x/3.x),只能使用 2.x 版本。
wget https://github.com/opencv/opencv/archive/refs/tags/2.4.13.7.tar.gz
tar xf 2.4.13.7.tar.gz
cd opencv-2.4.13.7/
mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE ..

这时会看到警告信息

CMake Warning at cmake/OpenCVPackaging.cmake:23 (message):
  CPACK_PACKAGE_VERSION does not match version provided by version.hpp
  header!
Call Stack (most recent call first):
  CMakeLists.txt:1103 (include)

需要对源码进行修改

vim ../cmake/OpenCVPackaging.cmake
## 在文件最开始,尚未引用变量 OPENCV_VCSVERSION 前添加下行定义
set(OPENCV_VCSVERSION "2.4.13.7")
## 然后重新执行预构
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make -j8
sudo make install

FREERDP

checking for FREERDP... no
configure: WARNING: Library freerdp >= 1.0.1 needed for freerdp was not found

FREERDP 组件官网:FreeRDP

在 Ubuntu 20.04 上可以直接使用仓库安装

sudo apt install freerdp2-dev

在 Ubuntu 22.04 上参考文章 Wiki

LIBBPG

https://bellard.org/bpg/

sudo apt install libsdl1.2-dev libsdl-image1.2-dev
wget https://bellard.org/bpg/libbpg-0.9.8.tar.gz
tar xf libbpg-0.9.8.tar.gz
cd libbpg-0.9.8/
make -j8
sudo make install

https://www.videolan.org/developers/x262.html
https://git.videolan.org/?p=x262.git;a=summary
https://github.com/mirror/x264/commit/a0cd7d38acb6c31973228ab207e18344920e0aa3


附录

参考链接

本文撰写于一年前,如出现图片失效或有任何问题,请在下方留言。博主看到后将及时修正,谢谢!
禁用 / 当前已拒绝评论,仅可查看「历史评论」。