Ubuntu23 编译VLC 播放RTSP

简述

由于开源协议的原因,Ubuntu 默认发行的VLC阉割掉了RTSP网络流播放,如果想要再Ubuntu上播放RTSP需要自行编译。 所以有了如此曲折的文章。。

欢迎转载,并请注明出处

必备条件

系统环境

  • Ubuntu 23.04
  • VLC 3.0.8

系统软件环境

  • GCC >= 13.0
  • Java = oracle java 1.8
  • 必须pass,否则一些库无法下载

设置代理

# 设置系统代理

export http_proxy=''
export https_proxy=''

# 设置 Git Http代理

git config --global http.proxy http://代理地址:端口号
git config --global https.proxy http://代理地址:端口号

# 或 Git 设置 socks5 代理
git config --global http.proxy socks5://代理地址:端口号
git config --global https.proxy socks5://代理地址:端口号

开始编译

安装依赖

sudo apt-get install git g++ make libtool automake autopoint pkg-config flex bison lua5.2

sudo apt-get install gperf
sudo apt-get install openjdk-8-jre-headless openjdk-8-jdk-headless
sudo apt-get install ant
sudo apt-get install meson
sudo apt-get install nasm

获取VLC

$ wget ftp://ftp.videolan.org/pub/videolan/vlc/3.0.8/vlc-3.0.8.tar.xz
$ tar xvJf vlc-3.0.8.tar.xz
$ cd vlc-3.0.8

获取VLC第三方库 Contrib

# 安装依赖
apt-get install subversion yasm cvs cmake ragel

# Configuration 
$ cd contrib
$ mkdir native
$ cd native
$ ../bootstrap
$ make

开始编译VLC

# 配置
./configure --disable-alsa  \
            --disable-chromaprint \ # 这里会影响音频功能
            --prefix=/usr/  # 安装到系统的目录,SharpVLC要求需要放再/usr/下

# 编译     
./make

# 运行测试
./vlc

# 安装到系统
./make install 

成功截图

Snapshot

问题解决

编译 Contrib

Error: inlining failed in call to always_inline ‘memory’:target specific option mismatch

/usr/include/bits/string3.h:50:1: error: inlining failed in call to
always_inline 'memcpy': target specific option mismatch
NTH (memcpy (void *restrict dest, const void *restrict __src,
^
/var/lib/abbs/build/tmp.FrJpnZY70I/libgcrypt-1.7.5/cipher/rijndael-ssse3-amd64.c:175:3:
note: called from here

memcpy(&ctx->keyschdec32[0][0], key, keybits / 8);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

应用一下链接的补丁即可, 注意这里Patch的不要自己手动去编辑补丁的文件,不要问我为什么!!!
https://dev.gnupg.org/T2882

## 验证patch
git apply --stat xxx_file.patch

## 应用patch
git app xxx_file.patch 

Can’t exec “gtkdocize”: No such file or directory

sudo apt install gtk-doc-tools

Libarchive gcc options error


# 编辑 libarchive rules
gedit ../vlc/contrib/src/libarchive/rules.mak

# 删除 ./configure 下的 --withou-iconv

# 重新 make
sudo make 

无法下载从bitbucket.org中下载x265-2.7.tar.bz2

修改下载地址如下:
https://get.videolan.org/x265/x265-2.7.tar.bz2


# 编辑 ../src/x265/rules.mak, 将 `X265_SNAPURL`替换如下

X265_SNAPURL := https://get.videolan.org/x265/x265-$(X265_VERSION).tar.bz2

libxcb 问题先安装依赖

# Ref https://wiki.videolan.org/UnixCompile/

> sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev

#For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:
> sudo apt-get install libx11-xcb-dev

libxcb => TabError: inconsistent use of tabs and spaces in indentation

提示如下:

cd libxcb && make install
make[1]: Entering directory '/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb'
Making install in src
make[2]: Entering directory '/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb/src'
  GEN      xproto.c
  File "/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb/src/./c_client.py", line 1937
    after_end_of_request = '(((char*)R) + R->length * 4)'
TabError: inconsistent use of tabs and spaces in indentation
make[2]: *** [Makefile:1290: xproto.c] Error 1
make[2]: Leaving directory '/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb/src'
make[1]: *** [Makefile:788: install-recursive] Error 1
make[1]: Leaving directory '/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb'
make: *** [../../contrib/src/xcb/rules.mak:57: .xcb] Error 2

原因为src/c_client.py混合使用了空格和tab, 手动编辑并改为空格.

# 编辑 c_client.py
sudo gedit c_client.py

# 手动替换所有 `\t` 替换为 8个空格

libxcb No module named ‘xcbgen’

Failed to load the xcbgen Python package!
Make sure that xcb/proto installed it on your Python path.
If not, you will need to create a .pth file or define $PYTHONPATH
to extend the path.
Refer to the README file in xcb/proto for more info.

Traceback (most recent call last):
  File "/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb/src/./c_client.py", line 3294, in <module>
    from xcbgen.state import Module
ModuleNotFoundError: No module named 'xcbgen'
make: *** [Makefile:1290: xproto.c] Error 1

sudo apt install python3-xcbgen

libxcb KeyError: ‘eventstruct’

  GEN      xproto.c
Traceback (most recent call last):
  File "/home/jins/vlc/vlc-3.0.8/contrib/native/libxcb/src/./c_client.py", line 3294, in <module>
    from xcbgen.state import Module
  File "/usr/lib/python3/dist-packages/xcbgen/state.py", line 12, in <module>
    from xcbgen import matcher
  File "/usr/lib/python3/dist-packages/xcbgen/matcher.py", line 17, in <module>
    from xcbgen.xtypes import *
  File "/usr/lib/python3/dist-packages/xcbgen/xtypes.py", line 1239, in <module>
    class EventStruct(Union):
  File "/usr/lib/python3/dist-packages/xcbgen/xtypes.py", line 1257, in EventStruct
    out = __main__.output['eventstruct']
          ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
KeyError: 'eventstruct'

参考 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892215

更新 libxcb 从 1.12 更新为 1.13
更新 xcb-proto 从 1.12 更新为 1.13

配置 VLC

configure: error: Package ‘alsa’, required by ‘virtual:world’, not found. alsa-lib 1.0.24 or later required. Pass --disable-alsa to ignore this error.

./configure --disable-alsa --disable-chromaprint

编译 VLC

libtool: error: ‘/usr/lib/libfontconfig.la’ is not a valid libtool archive

/usr/bin/sed: can’t read /usr/lib/libfontconfig.la: No such file or directory
libtool: error: ‘/usr/lib/libfontconfig.la’ is not a valid libtool archive
make[4]: *** [Makefile:16042: liblibbluray_plugin.la] Error 1
make[4]: Leaving directory ‘/home/jins/vlc/vlc-3.0.8/modules’
make[3]: *** [Makefile:27485: all-recursive] Error 1
make[3]: Leaving directory ‘/home/jins/vlc/vlc-3.0.8/modules’
make[2]: *** [Makefile:12539: all] Error 2
make[2]: Leaving directory ‘/home/jins/vlc/vlc-3.0.8/modules’
make[1]: *** [Makefile:1553: all-recursive] Error 1
make[1]: Leaving directory ‘/home/jins/vlc/vlc-3.0.8’
make: *** [Makefile:1438: all] Error 2

sudo apt remove libfontconfig1

live555.cpp:59:10: fatal error: liveMedia.hh: No such file or directory

手动进入 contrib/native/live555 编译

live555 Locale.hh:47:10: fatal error: xlocale.h: No such file or directory

sudo ln -s /usr/include/locale.h /usr/include/xlocale.h

https://github.com/rgaufman/live555/issues/12

libtool: warning: library ‘/home/jins/vlc/vlc-3.0.8/contrib/x86_64-linux-gnu/lib/libfontconfig.la’ was moved.

// 再次 sudo make 

sudo make 

libavcodec.a(fft.o): relocation R_X86_64_PC32 against symbol `ff_cos_32’ can not be used when making a shared object; recompile with -fPIC

/usr/bin/ld: /home/jins/vlc/vlc-3.0.8/contrib/x86_64-linux-gnu/lib/libavcodec.a(fft.o): warning: relocation against `ff_cos_512' in read-only section `.text'
/usr/bin/ld: /home/jins/vlc/vlc-3.0.8/contrib/x86_64-linux-gnu/lib/libavcodec.a(fft.o): relocation R_X86_64_PC32 against symbol `ff_cos_32' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

./configure --disable-alsa --disable-sout

cannot stat ‘.libs/liblibbluray_plugin.lai’: No such file or directory

# 可能liblibluray没有编译到, 再次编译.v
cd ./contrib/native 
sudo make 

参考文献

  • Wiki.VideoLan UnixCompile

    https://wiki.videolan.org/UnixCompile/

  • Source Code

    https://wiki.videolan.org/VLC_Source_code/

  • Why does this VLC Media Player Build Fail?

    https://stackoverflow.com/questions/53800021/why-does-this-vlc-media-player-build-fail

  • Can’t compile

    https://forum.videolan.org/viewtopic.php?t=147425

  • Ubuntu 升级GCC版本

    https://blog.csdn.net/quxuexi/article/details/121501679

  • Ubuntu如何优雅地切换gcc版本(编译“现代C++”程序)

    https://blog.csdn.net/L_Y_Fei/article/details/103405260

  • How to apply a patch generated with git format-patch?

    https://stackoverflow.com/questions/2249852/how-to-apply-a-patch-generated-with-git-format-patch

  • 如何编译 Live555

    http://www.live555.com/liveMedia/#config-unix

  • Getting started on LibVLCSharp for linux

    https://code.videolan.org/videolan/LibVLCSharp/-/blob/3.x/docs/linux-setup.md

  • 海康、大华等厂家监控摄像机rtsp地址格式

    https://zhuanlan.zhihu.com/p/348551470

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值