This article details the steps to install FFmpeg on a Sakura rental server. The instructions assume a basic understanding of terminal commands and Unix-like environments.
Prerequisites
Ensure that the necessary build tools and dependencies, such as gcc
, make
, and gmake
, are installed on your server.
Step 1: Download FFmpeg
Download the latest version of FFmpeg from the official website:
wget https://ffmpeg.org/releases/ffmpeg-7.0.2.tar.gz
Step 2: Extract the Archive
Extract the downloaded FFmpeg tarball:
tar xzvf ffmpeg-7.0.2.tar.gz
Step 3: Navigate to the FFmpeg Directory
Change to the FFmpeg directory:
cd ffmpeg-7.0.2
Step 4: Set Up Temporary Directory
Create a temporary directory for handling files during the configuration:
mkdir ~/tmp
export TMPDIR=~/tmp
Step 5: Install libfdk-aac
To enable AAC encoding with FFmpeg, you need to install libfdk-aac
. Follow these steps:
# Create a working directory
mkdir -p ~/src && cd ~/src
# Download the libfdk_aac source code
wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.2.tar.gz
# Extract the tarball
tar xzvf fdk-aac-2.0.2.tar.gz
# Navigate to the extracted directory
cd fdk-aac-2.0.2
# Configure and build
./configure --prefix=$HOME
make
make install
Step 6: Configure FFmpeg with Required Libraries
Set the PKG_CONFIG_PATH
to include your local installation of libfdk_aac
, then configure FFmpeg:
export PKG_CONFIG_PATH=$HOME/lib/pkgconfig:$PKG_CONFIG_PATH
# Configure FFmpeg with necessary libraries
cd ~/ffmpeg-7.0.2
./configure --prefix=${HOME} --enable-gpl --enable-nonfree --disable-x86asm \
--enable-libx264 --enable-libx265 --enable-libvpx --enable-libfdk-aac --enable-libmp3lame \
--extra-cflags=-I${HOME}/include --extra-ldflags=-L${HOME}/lib
Configuring FFmpeg for AAC Encoding Only
If you only need AAC encoding, use the following configuration options:
./configure --prefix=${HOME} --enable-gpl --enable-nonfree --disable-x86asm --enable-libfdk-aac
This option enables only the libfdk-aac
library, disabling unnecessary features, allowing you to build FFmpeg with minimal functionality.
Step 7: Compile and Install FFmpeg
Compile FFmpeg using the configuration options:
gmake
After building, you may manually copy the binaries to your bin directory:
install ffmpeg ~/bin
install ffprobe ~/bin
Step 8: Update Library Path
Update the LD_LIBRARY_PATH
to include your local library path:
echo 'export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH' >> ~/.zshrc
source ~/.zshrc
For Bash:
echo 'export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
Step 9: Verify the Installation
Check the installed version of FFmpeg:
ffmpeg --version
Step 10: Test FFmpeg
Navigate to the directory containing the audio files and test FFmpeg by converting or processing a file:
ffmpeg -i example.m4a output.mp3
Replace example.m4a
and output.mp3
with your actual file names.
[Note] Running FFmpeg Binaries on FreeBSD
Sakura rental servers operate on FreeBSD. Therefore, Linux-compiled FFmpeg binaries may not work, resulting in the following error:
ELF binary type "3" not known.
zsh: exec format error: ./ffmpeg
To resolve this, use FreeBSD-compatible binaries or build FFmpeg from source on your server.
You can now paste this English translation into your WordPress editor for publication.
Leave a Reply