ffmpeg installation (linux-centos)

  1. Download the ffmpeg source package ffmpeg-xxx.tar.bz2 from the official website, download address
  2. Unzip the bz2 installation package
tar -xjvf ffmpeg-3.3.1.tar.bz2

If the bzip2 package is missing, it needs to be installed first

yum install -y bzip2
  1. compile
cd ffmpeg-xxx/
./configure --enable-shared --prefix=/app/ffmpeg

Compilation possible error 1

  xxx-linux-gcc  is unable to create an executable file.

  C compiler test failed.

The gcc library is missing, the solution is to add gcc

yum install gcc

Compilation possible error 2

yasm/nasm not found or too old . Use --disable-yasm for a crippled build

The yasm/nasm package does not exist or is very old
Solution Install the yasm
download address to download the 1.3.0 source package, and execute the following commands in turn

tar -xvzf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make
make install
  1. Compile again and execute the following commands in sequence
cd ffmpeg-xxx/
./configure --enable-shared --prefix=/app/ffmpeg
make
make install

After the compilation is completed, four directories of bin, include, lib, and share will be generated in the /app/ffmpeg directory. Enter the bin directory and execute ./ffmpeg -version to view the details of the current version. Generally, the following errors will occur

./ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory

The reason is that the lib directory is not loaded into the link to the system library. The system ld directory list is in /etc/ld.so.conf. When you open the file, you will find that it references all the following /etc/ld.so.conf.d/ .conf file, such as mariadb-x86_64.conf, we only need to create a file and write the lib path, execute the command: vim /etc/ld.so.conf.d/ffmpeg.conf Then add a line: /app/ After ffmpeg/lib save and exit, then execute ldconfig to make the configuration take effect, now execute ./ffmpeg -version again and the display will be normal

ffmpeg version 4.0 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
configuration: --enable-shared --prefix=../../app/ffmpeg/
libavutil      56. 14.100 / 56. 14.100
libavcodec     58. 18.100 / 58. 18.100
libavformat    58. 12.100 / 58. 12.100
libavdevice    58.  3.100 / 58.  3.100
libavfilter     7. 16.100 /  7. 16.100
libswscale      5.  1.100 /  5.  1.100
libswresample   3.  1.100 /  3.  1.100
  1. test
./ffmpeg -i test.avi test2.mp4

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324852903&siteId=291194637