ffmpeg下载地址:http://ffmpeg.org/releases/

1.首先需要安装解码器集合(包含安装ffmpeg用到的所有解码器)下载地址:

链接:https://pan.baidu.com/s/1gxtRLmx20jhvBDHn3qBffA提取码: pwja

因为我的项目中使用x264的解码方式,所有我只安装该解码器。

代码地址:https://www.cnblogs.com/lemon2019/p/14106794.html

tar -xvf x264-master.tar.bz2
cd /usr/local/src/ffmpeg/x264-master/
./configure --prefix=/usr --enable-shared
make
make install

2.ffmpeg安装

tar -vxf ffmpeg-4.3.tar.bz2
./configure --prefix=/usr/local/ffmpeg2 --enable-libx264 --enable-gpl
make
make install
安装完成后执行:
/usr/local/ffmpeg2/bin/./ffmpeg 时出现

error while loading shared libraries: libavdevice.so.53: cannot open shared object file: No such file or director

错误,是因为共享库文件安装到了/usr/local/ffmpeg2/lib目录下, 那么把新共享库目录加入到共享库配置文件/etc/ld.so.conf中, 如下:

# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
# echo "/usr/local/ffmpeg2/lib" >> /etc/ld.so.conf
# ldconfig

再次执行   /usr/local/ffmpeg2/bin/./ffmpeg

如果出现如下版本信息则安装成功:

[root@xa-server150 ffmpeg]# /usr/local/ffmpeg2/bin/./ffmpeg
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix=/usr/local/ffmpeg2 --enable-libx264 --enable-gpl
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}... Use -h to get full help or, even better, run 'man ffmpeg'

3.验证视频格式转码:

[root@xa-server150 ffmpeg]#  /usr/local/ffmpeg2/bin/./ffmpeg -i /usr/local/src/ffmpeg/upload/111111.avi -c:v libx264 -mbd 0 -c:a aac -strict -2 -pix_fmt yuv420p -movflags faststart /usr/local/src/ffmpeg/upload/5552226.mp4
ffmpeg version 4.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36)
configuration: --prefix=/usr/local/ffmpeg2 --enable-libx264 --enable-gpl
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/usr/local/src/ffmpeg/upload/111111.avi':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : www.aliyun.com - Media Transcoding
Duration: 00:00:15.05, start: 0.000000, bitrate: 3875 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 640x360 [SAR 1:1 DAR 16:9], 3785 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x340e680] using SAR=1/1
[libx264 @ 0x340e680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x340e680] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 0x340e680] 264 - core 161 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/usr/local/src/ffmpeg/upload/5552226.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.91.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc58.91.100 aac
[mp4 @ 0x34119c0] Starting second pass: moving the moov atom to the beginning of the file.46x
frame= 360 fps= 57 q=-1.0 Lsize= 5128kB time=00:00:15.00 bitrate=2800.6kbits/s speed= 2.4x
video:4910kB audio:206kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.225184%
[libx264 @ 0x340e680] frame I:6 Avg QP:24.93 size: 27753
[libx264 @ 0x340e680] frame P:203 Avg QP:25.50 size: 13056
[libx264 @ 0x340e680] frame B:151 Avg QP:29.45 size: 14641
[libx264 @ 0x340e680] consecutive B-frames: 41.7% 4.4% 8.3% 45.6%
[libx264 @ 0x340e680] mb I I16..4: 15.4% 22.3% 62.2%
[libx264 @ 0x340e680] mb P I16..4: 3.2% 6.1% 14.8% P16..4: 28.4% 15.5% 12.8% 0.0% 0.0% skip:19.2%
[libx264 @ 0x340e680] mb B I16..4: 3.4% 4.5% 18.0% B16..8: 25.5% 18.4% 8.0% direct: 8.4% skip:13.8% L0:36.0% L1:29.3% BI:34.7%
[libx264 @ 0x340e680] 8x8 transform intra:21.8% inter:36.4%
[libx264 @ 0x340e680] coded y,uvDC,uvAC intra: 79.8% 76.4% 48.3% inter: 37.0% 31.5% 6.7%
[libx264 @ 0x340e680] i16 v,h,dc,p: 33% 20% 20% 26%
[libx264 @ 0x340e680] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 20% 23% 5% 6% 4% 7% 4% 8%
[libx264 @ 0x340e680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 19% 14% 5% 6% 4% 7% 4% 6%
[libx264 @ 0x340e680] i8c dc,h,v,p: 47% 20% 22% 11%
[libx264 @ 0x340e680] Weighted P-Frames: Y:16.3% UV:15.3%
[libx264 @ 0x340e680] ref P L0: 66.7% 20.3% 9.3% 3.3% 0.4%
[libx264 @ 0x340e680] ref B L0: 93.6% 5.2% 1.2%
[libx264 @ 0x340e680] ref B L1: 98.3% 1.7%
[libx264 @ 0x340e680] kb/s:2681.41
[aac @ 0x3443cc0] Qavg: 9249.240

到此转码已经完成!

如果需要安装多个解码器参考下面文章:

https://blog.csdn.net/wmt1432/article/details/51998164

最新文章

  1. JS基础之对象
  2. Neutron 理解 (9): OpenStack 是如何实现 Neutron 网络 和 Nova虚机 防火墙的 [How Nova Implements Security Group and How Neutron Implements Virtual Firewall]
  3. SQL Server中事务、锁定和阻塞
  4. simple_tag,filte,分页以及cookie和装饰器
  5. motto2
  6. idea让字体更圆滑
  7. 二、快速起步(Mysql镜像)
  8. 各大OJ
  9. WIN7下更改TFS连接用户的方法
  10. cocos2dx中的菜单项CCMenuItem及其五个子类的使用
  11. Chromuim开发机配置
  12. 读书笔记之 - javascript 设计模式 - 代理模式
  13. 2013第四届蓝桥杯决赛Java高职高专组题目以及解法答案
  14. 循环语句——for语句
  15. DBMS
  16. 我发起了一个 .Net 开源 跨平台 GUI (界面开发框架)项目 HtmlCore
  17. 工程设计文档服务EngineerCMS
  18. java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition的解决方案
  19. Linux下通过管道杀死所有与tomcat相关的进程
  20. @Transactional + FetchType.LYZY (hibernate) <---> Exception: could not initialize proxy - no Session;

热门文章

  1. acm一些小细节/技巧
  2. 同步FIFO学习笔记
  3. Linux踩坑之云服务器 ssh 连接不上
  4. [LeetCode题解]19. 删除链表的倒数第N个节点 | 双指针 + 一次遍历
  5. python-网络安全编程第三天(正则表达式)
  6. C++中new和malloc区别
  7. MathType中如何编辑求和公式
  8. FL Studio录制面板知识讲解
  9. php form表单提交时,action url中参数无效的解决方法
  10. P2943 [USACO09MAR]Cleaning Up G