Operations 7 min read

Offline Installation of FFmpeg on CentOS with Dependencies and RTSP‑to‑RTMP Streaming

This guide walks through the complete offline installation of FFmpeg on a CentOS server, covering prerequisite libraries (nasm, yasm, x264), verification of gcc and pkg‑config, compilation steps, troubleshooting missing x264, and finally using FFmpeg to pull an RTSP stream and push it to an RTMP server.

The Dominant Programmer
The Dominant Programmer
The Dominant Programmer
Offline Installation of FFmpeg on CentOS with Dependencies and RTSP‑to‑RTMP Streaming

The article starts by describing the need to install FFmpeg on a CentOS server that cannot access the internet, requiring offline installation of all dependencies.

1. Install nasm

Download nasm-2.14.tar.gz from

https://www.nasm.us/pub/nasm/releasebuilds/2.14/nasm-2.14.tar.gz

, upload it to /etc/nasm, extract with tar -xvf nasm-2.14.tar.gz, then run:

./configure
make && make install
nasm -version

2. Install yasm

Download yasm-1.3.0.tar.gz from

http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

, place it in /etc/yasm, extract with tar zxvf yasm-1.3.0.tar.gz, then run:

./configure
make && make install
yasm --version

3. Install x264

Obtain the source from https://www.videolan.org/developers/x264.html, upload the .tar.bz2 file to /etc/x264, extract with tar -jxvf x264-master.tar.bz2, then configure and compile:

./configure --enable-shared --enable-static
make && make install
x264 --version

4. Verify gcc and pkg‑config

Check the compiler and pkg‑config versions:

gcc --version
pkg-config --version

Both are assumed to be present.

5. Compile FFmpeg

Download ffmpeg-6.0.tar.xz from http://ffmpeg.org/releases/ffmpeg-6.0.tar.xz (or any version from the releases page), upload to the server, extract with tar -xvf ffmpeg-6.0.tar.xz, move the source to /usr/local/ffmpeg, and run:

./configure --enable-gpl --enable-libx264 --enable-static --disable-shared \
    --enable-encoder=libx264 --extra-libs=-ldl
make && make install

If no errors appear, FFmpeg is built successfully.

6. Troubleshooting: "ERROR: x264 not found using pkg-config"

The error occurs because the default x264 installation places the .pc file in a location not searched by pkg-config. Locate the library with: find / -name 'libx264.so.164' Move the found x264.pc file to /usr/share/pkgconfig:

sudo mv /usr/local/lib/pkgconfig/x264.pc /usr/share/pkgconfig

Then add /usr/local/lib/ to /etc/ld.so.conf, run ldconfig, and re‑run the FFmpeg configure command.

7. Pull RTSP and push to RTMP

With the RTMP server listening on port 11935, execute:

ffmpeg -i "rtsp://admin:123456@camera_ip:554/h264/ch01/main/av_stream" \
    -vcodec libx264 -acodec aac -f flv rtmp://rtmp_server_ip:11935/myapp/badao

The command pulls the Hikvision RTSP stream, encodes it with libx264 and aac, and streams it as FLV to the RTMP server. Verification can be done via the media server’s preview page.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxFFmpegVideo StreamingRTMPCentOSRTSPx264
The Dominant Programmer
Written by

The Dominant Programmer

Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.