解决在 Ubuntu18.04 上安装 ffmpeg 失败的方法

解决在 Ubuntu18.04 上安装 ffmpeg 失败的方法

一、问题描述

准备用 ffmpeg 对视频进行抽帧处理,结果发现系统没装这玩意,然后一装就来问题了:

cmd 复制代码
(base) root@a6tpt1b1mnhbu-0# apt install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 ffmpeg : Depends: libavdevice58 (= 7:4.2.7-0ubuntu0.1) but it is not going to be installed
          Depends: libavfilter7 (= 7:4.2.7-0ubuntu0.1)
          Depends: libavresample4 (= 7:4.2.7-0ubuntu0.1) but it is not going to be installed
          Depends: libpostproc55 (= 7:4.2.7-0ubuntu0.1) but it is not going to be installed
          Depends: libsdl2-2.0-0 (>= 2.0.10) but it is not going to be installed
 libibverbs1 : Breaks: ibverbs-providers (< 25~) but 17.1-1ubuntu0.2 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

报错了,说是依赖不足,且提示用apt --fix-broken install进行修复依赖问题对吧,结果我一运行又来问题了:

cmd 复制代码
(base) root@a6tpt1b1mnhbu-0# apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  g++-7 libapt-inst2.0 libgdbm5 libicu60 libisl19 libperl5.26 libstdc++-7-dev multiarch-support perl-modules-5.26
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  ibverbs-providers
The following packages will be upgraded:
  ibverbs-providers
1 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
175 not fully installed or removed.
Need to get 232 kB of archives.
After this operation, 310 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu focal/main amd64 ibverbs-providers amd64 28.0-1ubuntu1 [232 kB]
Fetched 232 kB in 2s (102 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 50553 files and directories currently installed.)
Preparing to unpack .../ibverbs-providers_28.0-1ubuntu1_amd64.deb ...
Unpacking ibverbs-providers:amd64 (28.0-1ubuntu1) over (17.1-1ubuntu0.2) ...
dpkg: error processing archive /var/cache/apt/archives/ibverbs-providers_28.0-1ubuntu1_amd64.deb (--unpack):
 unable to clean up mess surrounding './etc/libibverbs.d/bnxt_re.driver' before installing another version: Read-only file system
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/ibverbs-providers_28.0-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

说了一堆,但不是很懂,网上查阅了不少资料后,解决了这个问题

二、问题修复

先运行下面两条命令,第一条命令将尝试强制卸载 ibverbs-providers 包,即使在删除过程中出现问题也会强制执行。

然后,第二条命令将尝试修复依赖关系,并尽可能安装缺失的依赖项。

cmd 复制代码
sudo dpkg --purge --force-all ibverbs-providers
sudo apt --fix-broken install

如果上面的成果了,再次使用下面的命令,即可成功安装

cmd 复制代码
apt install ffmpeg

三、后记

搞了一天opencv编译了,没搞成功,各种问题,人已经要崩溃了;在这艰难的时间的里,唯有练练书法,逗逗小猫可以得到内心深处的放松。

愿我们在快节奏的时代里,找到自己的节奏,不慌不忙,踏实地、充实地过好每一天,爱惜自己的身体,爱自己,爱家人。

风雨人生,自己撑伞。

相关推荐
邪恶的贝利亚7 小时前
《ffplay 读线程与解码线程分析:从初始化到 seek 操作,对比视频与音频解码的差异》
ffmpeg·php·音视频
路溪非溪1 天前
关于ffmpeg的简介和使用总结
ffmpeg
gushansanren1 天前
基于WSL用MSVC编译ffmpeg7.1
windows·ffmpeg
追随远方3 天前
Android平台FFmpeg音视频开发深度指南
android·ffmpeg·音视频
charlie1145141914 天前
编译日志:关于编译opencv带有ffmpeg视频解码支持的若干办法
opencv·ffmpeg·音视频·imx6ull·移植教程
追随远方5 天前
Android平台FFmpeg视频解码全流程指南
android·ffmpeg·音视频
urhero6 天前
Python+ffmpeg 实现给视频添加字幕
ffmpeg·音视频·python编程·视频编辑·实用视频工具·添加字幕
追随远方6 天前
Android NDK版本迭代与FFmpeg交叉编译完全指南
android·ffmpeg
带鱼工作室6 天前
ffmpeg多媒体(音视频)处理常用命令
ffmpeg·音视频
批量小王子6 天前
2025-05-07-FFmpeg视频裁剪(尺寸调整,画面比例不变)
ffmpeg·音视频