ubuntu22.04 安装ffmpeg

ubuntu22.04 安装ffmpeg

bash 复制代码
wget https://ffmpeg.org/releases/ffmpeg-7.0.1.tar.xz
tar -xvf ffmpeg-7.0.1.tar.xz
sudo apt-get install gcc g++ cmake make pkgconf -y
mkdir -p ~/util/ffmpeg/lib
cd ffmpeg-7.0.1
./configure --prefix="/home/ip3/util/ffmpeg" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-cflags=-I/home/ip3/util/ffmpeg/include --extra-ldflags=-L/home/ip3/util/ffmpeg/lib

缺少库文件之后 安装下面的文件,不安装可能会报各种错误

bash 复制代码
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -zxvf yasm-1.3.0.tar.gz
cd yasm-1.3.0
./configure --prefix=/home/ip3/util/ffmpeg
make -j16
sudo make install
export PATH=$PATH:/home/ip3/util/ffmpeg/bin

wget https://zenlayer.dl.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-2.0.3.tar.gz
tar -zxvf fdk-aac-2.0.3.tar.gz
cd fdk-aac-2.0.3/
./configure --prefix=/home/ip3/util/ffmpeg/
make -j16
sudo make install
export PKG_CONFIG_PATH=/home/cat/util/ffmpeg/lib/pkgconfig/

wget https://zenlayer.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar -zxvf lame-3.100.tar.gz
cd lame-3.100/
./configure --enable-shared --prefix=/home/ip3/util/ffmpeg/
make -j16
sudo make install

ERROR: speex not found using pkg-config

wget https://ftp.osuosl.org/pub/xiph/releases/speex/speex-1.2.1.tar.gz
tar -zxvf speex-1.2.1.tar.gz
cd speex-1.2.1/
./configure --prefix=/home/ip3/util/ffmpeg/
make -j16
sudo make install


ERROR: x264 not found using pkg-config

wget https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.bz2
tar -jxvf x264-master.tar.bz2
cd x264-master/
./configure --prefix=/home/ip3/util/ffmpeg/ --disable-asm --enable-static --enable-shared
make -j16
sudo make install


ERROR: x265 not found using pkg-config

wget http://ftp.videolan.org/pub/videolan/x265/x265_3.2.tar.gz
tar -zxvf x265_3.2.tar.gz
cd x265_3.2/build/linux
./make-Makefiles.bash
make -j16
sudo make install


wget https://github.com/libsdl-org/SDL/archive/refs/tags/release-2.30.5.tar.gz
tar -zxvf release-2.30.5.tar.gz
cd SDL-release-2.30.5
./configure --prefix=/home/ip3/util/ffmpeg/
make -j16
sudo make install


cd cd ffmpeg-7.0.1
./configure --prefix="/home/ip3/util/ffmpeg" --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-cflags=-I/home/ip3/util/ffmpeg/include --extra-ldflags=-L/home/ip3/util/ffmpeg/lib
make -j16
sudo make install

将ffmpeg程序目录添加到PATH

sudo vim ~/.bashrc,在profile文件末尾添加export PATH="/home/ip3/util/ffmpeg/bin/:$PATH",将/home/ip3/util/ffmpeg/bin/替换为ffmpeg的安装目录

bash 复制代码
export PATH="/home/ip3/util/ffmpeg/bin/:$PATH"

sudo vim /etc/ld.so.conf,在ld.so.conf文件末尾添加库文件路径/home/ip3/util/ffmpeg/lib,执行ldconfig命令

ffmpeg 转换mp4到h264文件

bash 复制代码
Projects/video$ ffmpeg -i 190204084208765161.mp4  -vcodec h264 xxx.h264
ffmpeg version 7.0.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
  configuration: --prefix=/home/ip3/util/ffmpeg --enable-gpl --enable-nonfree --enable-ffplay --enable-libfdk-aac --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-filter=delogo --enable-debug --disable-optimizations --enable-libspeex --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --extra-cflags=-I/home/ip3/util/ffmpeg/include --extra-ldflags=-L/home/ip3/util/ffmpeg/lib
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '190204084208765161.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : www.aliyun.com - Media Transcoding
  Duration: 00:00:31.09, start: 0.000000, bitrate: 1092 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1000x416 [SAR 3328:3325 DAR 320:133], 958 kb/s, 24 fps, 24 tbr, 12288 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x5d059dcfe680] using SAR=3328/3325
[libx264 @ 0x5d059dcfe680] using cpu capabilities: none!
[libx264 @ 0x5d059dcfe680] profile High, level 3.1, 4:2:0, 8-bit
Output #0, h264, to 'xxx.h264':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf61.1.100
  Stream #0:0(und): Video: h264, yuv420p(tv, bt709, progressive), 1000x416 [SAR 3328:3325 DAR 320:133], q=2-31, 24 fps, 24 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.3.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[out#0/h264 @ 0x5d059dd00540] video:3556KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.000000%
frame=  746 fps= 74 q=-1.0 Lsize=    3556KiB time=00:00:31.00 bitrate= 939.7kbits/s speed=3.05x
[libx264 @ 0x5d059dcfe680] frame I:35    Avg QP:18.85  size: 18159
[libx264 @ 0x5d059dcfe680] frame P:325   Avg QP:22.46  size:  6011
[libx264 @ 0x5d059dcfe680] frame B:386   Avg QP:23.88  size:  2726
[libx264 @ 0x5d059dcfe680] consecutive B-frames: 21.6% 23.1% 15.7% 39.7%
[libx264 @ 0x5d059dcfe680] mb I  I16..4: 33.1% 40.6% 26.3%
[libx264 @ 0x5d059dcfe680] mb P  I16..4: 19.6% 20.7%  2.4%  P16..4: 26.3%  7.1%  2.1%  0.0%  0.0%    skip:21.8%
[libx264 @ 0x5d059dcfe680] mb B  I16..4:  3.3%  4.5%  0.7%  B16..8: 29.5%  4.7%  0.7%  direct: 1.9%  skip:54.6%  L0:49.0% L1:45.6% BI: 5.4%
[libx264 @ 0x5d059dcfe680] 8x8 transform intra:47.8% inter:70.8%
[libx264 @ 0x5d059dcfe680] coded y,uvDC,uvAC intra: 32.3% 56.0% 9.5% inter: 8.8% 11.6% 0.2%
[libx264 @ 0x5d059dcfe680] i16 v,h,dc,p: 29% 24% 12% 34%
[libx264 @ 0x5d059dcfe680] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 21% 27%  5%  4%  4%  4%  5%  5%
[libx264 @ 0x5d059dcfe680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 20% 15%  7%  8%  7%  7%  6%  6%
[libx264 @ 0x5d059dcfe680] i8c dc,h,v,p: 51% 22% 20%  6%
[libx264 @ 0x5d059dcfe680] Weighted P-Frames: Y:5.8% UV:4.9%
[libx264 @ 0x5d059dcfe680] ref P L0: 71.7% 13.5% 11.2%  3.6%  0.1%
[libx264 @ 0x5d059dcfe680] ref B L0: 90.4%  8.3%  1.3%
[libx264 @ 0x5d059dcfe680] ref B L1: 98.5%  1.5%
[libx264 @ 0x5d059dcfe680] kb/s:937.16

如果安装之后缺少还某些库文件 ,重新编译对应的库文件,不要配置--prefix=/home/ip3/util/ffmpeg/

会自动安装到 /usr/local/lib目录下

相关推荐
runing_an_min1 小时前
ffmpeg视频滤镜:替换部分帧-freezeframes
ffmpeg·音视频·freezeframes
ruizhenggang1 小时前
ffmpeg本地编译不容易发现的问题 — Error:xxxxx not found!
ffmpeg
runing_an_min3 小时前
ffmpeg视频滤镜:提取缩略图-framestep
ffmpeg·音视频·framestep
韩曙亮16 小时前
【FFmpeg】FFmpeg 内存结构 ③ ( AVPacket 函数简介 | av_packet_ref 函数 | av_packet_clone 函数 )
ffmpeg·音视频·avpacket·av_packet_clone·av_packet_ref·ffmpeg内存结构
oushaojun220 小时前
ubuntu中使用ffmpeg和nginx推流rtmp视频
nginx·ubuntu·ffmpeg·rtmp
莫固执,朋友21 小时前
网络抓包工具tcpdump 在海思平台上的编译使用
网络·ffmpeg·音视频·tcpdump
lxkj_20241 天前
修改ffmpeg实现https-flv内容加密
网络协议·https·ffmpeg
cuijiecheng20181 天前
音视频入门基础:MPEG2-TS专题(6)——FFmpeg源码中,获取MPEG2-TS传输流每个transport packet长度的实现
ffmpeg·音视频
VisionX Lab1 天前
数据脱敏工具:基于 FFmpeg 的视频批量裁剪
python·ffmpeg·音视频
柳鲲鹏2 天前
全网首发:Ubuntu编译跨平台嵌入式支持ffmpeg的OpenCV
linux·ubuntu·ffmpeg