ffmpeg在linux环境的安装过程

1、ffmpeg安装过程

[root@localhost src]# pwd
/usr/local/src
[root@localhost src]# wget http://ffmpeg.org/releases/ffmpeg-4.4.tar.xz  
--2021-08-11 17:28:38--  http://ffmpeg.org/releases/ffmpeg-4.4.tar.xz
Resolving ffmpeg.org (ffmpeg.org)... 79.124.17.100
Connecting to ffmpeg.org (ffmpeg.org)|79.124.17.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9557868 (9.1M) [application/x-xz]
Saving to: ‘ffmpeg-4.4.tar.xz’

100%[================================================================================================================>] 9,557,868   3.34MB/s   in 2.7s   

2021-08-11 17:28:47 (3.34 MB/s) - ‘ffmpeg-4.4.tar.xz’ saved [9557868/9557868]

[root@localhost src]# ls
ffmpeg-4.4.tar.xz 
[root@localhost src]# tar -xvJf ffmpeg-4.4.tar.xz 
ffmpeg-4.4/
ffmpeg-4.4/Makefile
ffmpeg-4.4/libavcodec/
ffmpeg-4.4/libavcodec/roqvideo.h
ffmpeg-4.4/libavcodec/txd.c
ffmpeg-4.4/libavcodec/h264dsp_template.c
ffmpeg-4.4/libavcodec/v4l2_context.c
...
ffmpeg-4.4/README.md
[root@localhost src]# 
[root@localhost src]# cd ffmpeg-4.4/
[root@localhost ffmpeg-4.4]# ./configure --prefix=/usr/local/ffmpeg
nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
[root@localhost ffmpeg-4.4]# 
[root@localhost ffmpeg-4.4]# cd ..
[root@localhost src]# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
--2021-08-11 17:39:41--  http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
Resolving www.tortall.net (www.tortall.net)... 69.55.235.23
Connecting to www.tortall.net (www.tortall.net)|69.55.235.23|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1492156 (1.4M) [application/octet-stream]
Saving to: ‘yasm-1.3.0.tar.gz’

100%[================================================================================================================>] 1,492,156    321KB/s   in 4.5s   

2021-08-11 17:39:53 (321 KB/s) - ‘yasm-1.3.0.tar.gz’ saved [1492156/1492156]

[root@localhost src]# 
[root@localhost src]# tar zxvf yasm-1.3.0.tar.gz
yasm-1.3.0/
yasm-1.3.0/libyasm/
yasm-1.3.0/libyasm/cmake-module.c
yasm-1.3.0/libyasm/bitvect.h
yasm-1.3.0/libyasm/section.h
...
yasm-1.3.0/ABOUT-NLS
[root@localhost src]# 
[root@localhost src]# cd yasm-1.3.0/
[root@localhost yasm-1.3.0]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
...
config.status: creating po/POTFILES
config.status: creating po/Makefile
[root@localhost yasm-1.3.0]# 
[root@localhost yasm-1.3.0]# make && make install
gcc -std=gnu99  -I.  \
  -c -o genperf.o `test -f tools/genperf/genperf.c || echo './'`tools/genperf/genperf.c
gcc -std=gnu99  -I.  \
  -c -o gp-perfect.o `test -f tools/genperf/perfect.c || echo './'`tools/genperf/perfect.c
  ...
make[3]: Leaving directory `/usr/local/src/yasm-1.3.0'
make[2]: Leaving directory `/usr/local/src/yasm-1.3.0'
make[1]: Leaving directory `/usr/local/src/yasm-1.3.0'
[root@localhost yasm-1.3.0]#
[root@localhost yasm-1.3.0]# cd ../ffmpeg-4.4/
[root@localhost ffmpeg-4.4]# ./configure --prefix=/usr/local/ffmpeg
install prefix            /usr/local/ffmpeg
source path               .
C compiler                gcc
C library                 glibc
...
Enabled indevs:
alsa                    fbdev                   lavfi                   oss                     v4l2                    xcbgrab

Enabled outdevs:
alsa                    fbdev                   oss                     v4l2                    xv

License: LGPL version 2.1 or later
[root@localhost ffmpeg-4.4]# make && make install
GEN     libavutil/libavutil.version
GEN     libswscale/libswscale.version
GEN     libswresample/libswresample.version
GEN     libavcodec/libavcodec.version
...
INSTALL libavutil/avconfig.h
INSTALL libavutil/ffversion.h
INSTALL libavutil/libavutil.pc
[root@localhost ffmpeg-4.4]# 
[root@localhost ffmpeg-4.4]# /usr/local/ffmpeg/bin/ffmpeg -version
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --prefix=/usr/local/ffmpeg
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
[root@localhost ffmpeg-4.4]# 

2、在转换视频的时候报错,这是在安装ffmpeg时没有安装libx264库导致,需要各种安装包

[20210812 09:49:27:486] [INFO] - com.kunpeng.common.video.ConvertToM3U8.doWaitFor(ConvertToM3U8.java:145) - 转换后信息:ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
  configuration: --prefix=/usr/local/ffmpeg
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/root/kunpeng/filepath/video/407f2b931c8b4ccfa07e459abe9f191b//407f2b931c8b4ccfa07e459abe9f191b.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.58.101
  Duration: 00:02:11.15, start: 0.000000, bitrate: 432 kb/s
  Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1432x856, 377 kb/s, 30 fps, 30 tbr, 15360 tbn, 30720 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 48 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
Unknown encoder 'libx264'

[root@localhost src]# git clone https://code.videolan.org/videolan/x264.git    
Cloning into 'x264'...
remote: Enumerating objects: 22884, done.
remote: Counting objects: 100% (416/416), done.
remote: Compressing objects: 100% (279/279), done.
remote: Total 22884 (delta 202), reused 330 (delta 137), pack-reused 22468
Receiving objects: 100% (22884/22884), 6.12 MiB | 2.58 MiB/s, done.
Resolving deltas: 100% (18842/18842), done.
[root@localhost src]# cd x264/
[root@localhost x264]# 
[root@localhost x264]# ./configure --prefix=/usr/local/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
Found no assembler
Minimum version is nasm-2.13
If you really want to compile without asm, configure with --disable-asm.
[root@localhost x264]# 
[root@localhost src]# wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.gz
--2021-08-12 10:01:44--  https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.gz
Resolving www.nasm.us (www.nasm.us)... 198.137.202.136, 2607:7c80:54:e::136
Connecting to www.nasm.us (www.nasm.us)|198.137.202.136|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1629366 (1.6M) [application/gzip]
Saving to: ‘nasm-2.15.05.tar.gz’

100%[================================================================================================================>] 1,629,366   1.60MB/s   in 1.0s   

2021-08-12 10:01:51 (1.60 MB/s) - ‘nasm-2.15.05.tar.gz’ saved [1629366/1629366]

[root@localhost src]# 
[root@localhost src]# tar -zxvf nasm-2.15.05.tar.gz 
nasm-2.15.05/
nasm-2.15.05/AUTHORS
nasm-2.15.05/.travis.yml
nasm-2.15.05/.gitattributes
...
nasm-2.15.05/doc/nasmdoc.src
nasm-2.15.05/doc/warnings.src
nasm-2.15.05/doc/psfonts.ph
nasm-2.15.05/doc/nasmlogw.png
[root@localhost src]# 
[root@localhost src]# cd nasm-2.15.05/
[root@localhost nasm-2.15.05]# 
[root@localhost nasm-2.15.05]# ./configure --prefix=/usr/local/nasm-2.15.05/
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating config/config.h
[root@localhost nasm-2.15.05]# 
[root@localhost nasm-2.15.05]# make && make install
/usr/bin/mkdir -p stdlib nasmlib output asm disasm x86 common macros test doc nsis rdoff
make nasm ndisasm rdf
make[1]: Entering directory `/usr/local/src/nasm-2.15.05'
make[1]: Circular asm/warnings.c <- asm/warnings.time dependency dropped.
...
/usr/bin/mkdir -p /usr/local/nasm-2.15.05/share/man/man1
/usr/bin/install -c -m 644 ./nasm.1 /usr/local/nasm-2.15.05/share/man/man1/nasm.1
/usr/bin/install -c -m 644 ./ndisasm.1 /usr/local/nasm-2.15.05/share/man/man1/ndisasm.1
[root@localhost nasm-2.15.05]# 
[root@localhost ~]# vi .bash_profile
配置path
[root@localhost ~]# . .bash_profile 
[root@localhost src]# cd x264/
[root@localhost x264]#  ./configure --prefix=/usr/local/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared
platform:       X86_64
byte order:     little-endian
system:         LINUX
cli:            yes
libx264:        internal
shared:         yes
static:         no
bashcompletion: yes
asm:            yes
interlaced:     yes
avs:            avxsynth
lavf:           no
ffms:           no
mp4:            no
gpl:            yes
thread:         posix
opencl:         yes
filters:        crop select_every
lto:            no
debug:          no
gprof:          no
strip:          no
PIC:            yes
bit depth:      all
chroma format:  all

You can run 'make' or 'make fprofiled' now.
[root@localhost x264]# 
[root@localhost x264]# make
cat common/opencl/x264-cl.h common/opencl/motionsearch.cl common/opencl/subpel.cl common/opencl/intra.cl common/opencl/weightp.cl common/opencl/downscale.cl 
common/opencl/bidir.cl | ./tools/cltostr.sh common/oclobj.h
dependency file generation...
...
is-64-10.o common/x86/bitstream-a-10.o common/x86/const-a-10.o common/x86/cabac-a-10.o common/x86/dct-a-10.o common/x86/deblock-a-10.o common/x86/mc-a-10.o 
common/x86/mc-a2-10.o common/x86/pixel-a-10.o common/x86/predict-a-10.o common/x86/quant-a-10.o common/x86/sad16-a-10.o   -shared -Wl,-soname,libx264.so.164  
-Wl,-Bsymbolic -m64  -lm -lpthread -ldl 
[root@localhost x264]# 
[root@localhost x264]# make install
install -d /usr/local/x264//bin
install x264 /usr/local/x264//bin
install -d /usr/local/include /usr/local/lib/pkgconfig
install -m 644 ./x264.h x264_config.h /usr/local/include
install -m 644 x264.pc /usr/local/lib/pkgconfig
install -d /usr/local/lib
ln -f -s libx264.so.164 /usr/local/lib/libx264.so
install -m 755 libx264.so.164 /usr/local/lib
install -d /usr/share/bash-completion/completions
install -m 644 ./tools/bash-autocomplete.sh /usr/share/bash-completion/completions/x264
[root@localhost x264]# 
[root@localhost x264]# cd ../ffmpeg-4.4/
[root@localhost ffmpeg-4.4]# ./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-shared --enable-libx264
...
libavdevice/indev_list.c is unchanged
libavdevice/outdev_list.c is unchanged
libavformat/protocol_list.c is unchanged
[root@localhost ffmpeg-4.4]# 
[root@localhost ffmpeg-4.4]# make clean
[root@localhost ffmpeg-4.4]# make
...
LD      ffmpeg_g
STRIP   ffmpeg
CC      fftools/ffprobe.o
LD      ffprobe_g
STRIP   ffprobe
[root@localhost ffmpeg-4.4]# 
[root@localhost ffmpeg-4.4]# make install
INSTALL libavdevice/libavdevice.a
INSTALL libavdevice/libavdevice.so
STRIP   install-libavdevice-shared
...
INSTALL libavutil/libavutil.pc
[root@localhost ffmpeg-4.4]# 

3、还是报错,需要增加配置

[20210812 10:46:16:623] [INFO] - com.kunpeng.common.video.ConvertToM3U8.doWaitFor(ConvertToM3U8.java:145) - 转换后信息:/usr/local/ffmpeg/bin/ffmpeg: 
error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory

[root@localhost ffmpeg-4.4]# vi /etc/ld.so.conf
/usr/local/ffmpeg/lib
[root@localhost ffmpeg-4.4]# 
[root@localhost ffmpeg-4.4]# ldconfig

[20210812 10:54:00:153] [INFO] - com.kunpeng.common.video.ConvertToM3U8.doWaitFor(ConvertToM3U8.java:145) - 转换后信息:/usr/local/ffmpeg/bin/ffmpeg: 
error while loading shared libraries: libx264.so.164: cannot open shared object file: No such file or directory

[root@localhost ffmpeg-4.4]# vi /etc/ld.so.conf
/usr/local/lib
[root@localhost ffmpeg-4.4]# ldconfig
[root@localhost ffmpeg-4.4]# 

最新全套Jar: FFMPEG3.4.1+JavaCV1.4.1+OpenCV3.4.1-含windows&linux;平台链接库。安卓和macos的链接库将另发。 请根据平台选择适当的链接库。 artoolkitplus-linux-armhf.jar artoolkitplus-linux-ppc64le.jar artoolkitplus-linux-x86.jar artoolkitplus-linux-x86_64.jar artoolkitplus-platform.jar artoolkitplus-windows-x86.jar artoolkitplus-windows-x86_64.jar artoolkitplus.jar ffmpeg-linux-armhf.jar ffmpeg-linux-ppc64le.jar ffmpeg-linux-x86.jar ffmpeg-linux-x86_64.jar ffmpeg-platform.jar ffmpeg-windows-x86.jar ffmpeg-windows-x86_64.jar ffmpeg.jar flandmark-linux-armhf.jar flandmark-linux-ppc64le.jar flandmark-linux-x86.jar flandmark-linux-x86_64.jar flandmark-platform.jar flandmark-windows-x86.jar flandmark-windows-x86_64.jar flandmark.jar flycapture-linux-armhf.jar flycapture-linux-x86.jar flycapture-linux-x86_64.jar flycapture-platform.jar flycapture-windows-x86.jar flycapture-windows-x86_64.jar flycapture.jar javacpp.jar javacv-platform.jar javacv.jar libdc1394-linux-armhf.jar libdc1394-linux-ppc64le.jar libdc1394-linux-x86.jar libdc1394-linux-x86_64.jar libdc1394-platform.jar libdc1394-windows-x86.jar libdc1394-windows-x86_64.jar libdc1394.jar libfreenect-linux-armhf.jar libfreenect-linux-ppc64le.jar libfreenect-linux-x86.jar libfreenect-linux-x86_64.jar libfreenect-platform.jar libfreenect-windows-x86.jar libfreenect-windows-x86_64.jar libfreenect.jar libfreenect2-linux-x86.jar libfreenect2-linux-x86_64.jar libfreenect2-platform.jar libfreenect2-windows-x86_64.jar libfreenect2.jar librealsense-linux-x86.jar librealsense-linux-x86_64.jar librealsense-platform.jar librealsense-windows-x86.jar librealsense-windows-x86_64.jar librealsense.jar opencv-ios-arm64.jar opencv-ios-x86_64.jar opencv-linux-armhf.jar opencv-linux-ppc64le.jar opencv-linux-x86.jar opencv-linux-x86_64.jar opencv-platform.jar opencv-windows-x86.jar opencv-windows-x86_64.jar opencv.jar videoinput-platform.jar videoinput-windows-x86.jar videoinput-windows-x86_64.jar videoinput.jar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

psyuhen

你的鼓励是我最大的动力谢谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值