文章参考了http://blog.csdn.net/lintianlin/article/details/44651199,特此感谢作者?
Linux下安装视频转换工具ffmpeg
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 2.ffmpeg安装 tar -vxf ffmpeg-4.3.tar.bz2 安装完成后执行:
/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/222221.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 Input #0,mov,mp4,m4a,3gp,3g2,mj2,from '/usr/local/src/ffmpeg/upload/222221.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 () 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,to '/usr/local/src/ffmpeg/upload/5552226.mp4' compatible_brands: isomiso2avc1mp41 encoder : Lavf58.45.100 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661),yuv420p,q=-1--1,24 tbc () 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),128 kb/s () 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,ddl,ddr,vr,hd,vl,hu: 23% 20% 23% 5% 6% 4% 7% 4% 8% [libx264 @ 0x340e680] i4 v,hu: 33% 19% 14% 5% 6% 4% 7% 4% 6% [libx264 @ 0x340e680] i8c dc,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 到此转码已经完成! ? ? ? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |