创建容器
docker run -it -v /mnt/f/ffmpeg:/mnt/f/ffmpeg --name ffmpeg 49a981f2b85f /bin/bash
在 Linux 上编译 FFmpeg:
安装依赖库:
sudo apt-get update
sudo apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget
下载 FFmpeg 源代码:
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
#查看远程分支
git branch -r
#切换分支
git checkout -b origin/release/5.1 origin/release/5.1
配置和编译:
./configure --enable-shared
make -j20 # 使用多个核心进行编译,可以根据你的 CPU 核心数进行调整
sudo make install
上述命令假设你在 FFmpeg 源代码目录下执行。–enable-shared 表示编译生成共享库。
WARNING: pkg-config not found, library detection may fail.
sudo apt-get update
sudo apt-get install pkg-config
No rule to make target ‘libavcodec/x86/lpc.asm’, needed by ‘libavcodec/x86/lpc.o’. Stop
sudo apt-get update
sudo apt-get install yasm
安装路径
root@cec0f3db763d:~# whereis ffmpeg
ffmpeg: /usr/local/bin/ffmpeg
配置环境
sudo gedit /etc/ld.so.conf
加入一行
安装成功
root@cec0f3db763d:~# ffmpeg
ffmpeg version n5.1.4-1-gae14d9c06b Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
configuration: --enable-shared
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 13.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
切换到挂载目录
cd /mnt/f/ffmpeg/
查询视频信息
ffprobe IVR_20231214_172440.mp4
root@cec0f3db763d:/mnt/f/ffmpeg# ffprobe IVR_20231214_170605.mp4
ffprobe version n5.1.4-1-gae14d9c06b Copyright (c) 2007-2023 the FFmpeg developers
built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.2)
configuration: --enable-shared
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 13.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'IVR_20231214_170605.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:00:10.40, start: 0.000000, bitrate: 3459 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt470bg/bt470bg/bt709, progressive), 1024x768, 3455 kb/s, 42.22 fps, 50 tbr, 90k tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
提取所有帧
ffmpeg -i VID_20231214_091908.mp4 -vf "select=1" -vsync vfr frame/%04d.jpg
ffmpeg -i VID_20231214_091908.mp4 -vf "select=gt(scene\,0.1)" -vsync vfr frame/%04d.jpg