如何在CentOS 6上安装FFmpeg?求助安装失败解决方案
Hey, sorry to hear you've been stuck installing FFmpeg on CentOS 6 for two days—let's break this down. The core problem here is that CentOS 6 reached end-of-life (EOL) back in 2020, so its default software repositories are no longer maintained or accessible. That's almost certainly why the third-party script and tutorials you tried aren't working. Let's get this sorted:
Step 1: Replace CentOS 6's Dead System Repositories
First, we need to point your system to the archived CentOS 6 repositories (since the official ones are gone):
- Back up your old repo config to avoid mess:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- Create a new repo file pointing to CentOS's vault server:
cat > /etc/yum.repos.d/CentOS-Base.repo <<EOF [CentOS-Base] name=CentOS-6 - Base baseurl=http://vault.centos.org/6.10/os/\$basearch/ gpgcheck=1 gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6 EOF
- Refresh your yum cache to pick up the new repo:
yum clean all && yum makecache
Step 2: Install Required Build Dependencies
CentOS 6 has outdated packages, so we need to install all the tools and libraries needed to compile FFmpeg from source (this is more reliable than third-party scripts right now):
yum install -y gcc gcc-c++ make automake autoconf libtool git nasm pkgconfig yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel libxml2-devel libxslt-devel yum install -y libvorbis-devel libtheora-devel libogg-devel
Step 3: Compile FFmpeg Manually (Recommended)
FFmpeg 8.0 is likely too new for CentOS 6's old system libraries, so we'll use a stable, compatible version (4.4.x):
- Download the source code:
wget https://ffmpeg.org/releases/ffmpeg-4.4.4.tar.gz tar -xvzf ffmpeg-4.4.4.tar.gz cd ffmpeg-4.4.4
- Configure the build with options that work for CentOS 6:
./configure --prefix=/usr/local/ffmpeg --enable-shared --disable-static --enable-gpl --enable-version3 --enable-nonfree --enable-libvorbis --enable-libtheora --enable-libogg
- Compile and install (use
-j$(nproc)to speed up compilation with all your CPU cores):
make -j$(nproc) make install
- Add FFmpeg to your system's PATH so you can run it from anywhere:
echo 'export PATH=/usr/local/ffmpeg/bin:$PATH' >> /etc/profile echo 'export LD_LIBRARY_PATH=/usr/local/ffmpeg/lib:$LD_LIBRARY_PATH' >> /etc/profile source /etc/profile
Step 4: Verify the Installation
Run this command to confirm FFmpeg is working:
ffmpeg -version
If you run into any errors during compilation, check the output for missing dependencies—you can install them via yum using the archived repo we set up earlier.
内容的提问来源于stack exchange,提问作者sam67

