ps: 从笔记中迁移至blog
版本概述
Windows 基于win10
Linux 基于CentOS 7.6
一.Windows安装笔记
1.下载安装
https://ffmpeg.org/download.html
2 解压缩,拷贝到需要目录,重命名
3 追加环境变量
echo %PATH%
setx /m PATH "%PATH%;F:\dev_tools\ffmpeg\bin"
4 重启cmd验证
ffmpeg -version
5.测试命令
查询所有设备
ffmpeg -list_devices true -f dshow -i dummy
查询具体设备信息, 如:摄像头
ffmpeg -f dshow -list_options true -i video="Integrated Camera"
二.Linux安装ffmpeg
1 下载
wget https://johnvansickle.com/ffmpeg/release-source/ffmpeg-4.1.tar.xz
2 解压&安装
ps: 如果需要安装x264 ,请跳过该步骤 直接安装yasm 和nasm
tar -Jxvf ffmpeg-4.1.tar.xz
cd ffmpeg-4.1
sudo ./configure --prefix=/usr/local/ffmpeg
sudo make & make install
2.1 发生错误: nasm/yasm not found
2.2 请先安装yasm
2.2.1 在线安装
yum install yasm
2.2.2 离线安装
rpm -ivh epel-release-7-13.noarch.rpm
rpm -ivh yasm-1.2.0-4.el7.x86_64.rpm
yasm --version
3 添加环境变量
sudo vi /etc/profile
export FFMEPG=/usr/local/ffmpeg
export PATH=${FFMEPG}/bin:${PATH}
source /etc/profile
4. 配置X264
4.1 安装nasm
4.1.1 在线安装
yum install build-essential nasm
4.1.2 离线安装
wget https://www.nasm.us/pub/nasm/releasebuilds/2.13.03/nasm-2.13.03.tar.gz
tar -zxvf nasm-2.13.03.tar.gz
cd nasm-2.13.03/
sudo ./configure --prefix=/usr/local/nasm && make
sudo make install
export PATH=/usr/local/nasm/bin:${PATH}
nasm -v
4.2 安装x264
git clone https://code.videolan.org/videolan/x264.git
cd x264
./configure --prefix=/usr/softinstall/x264/ --includedir=/usr/local/include --libdir=/usr/local/lib --enable-shared --enable-static --disable-asm
make&& make install
4.3 重新编译ffmpeg 命令
./configure --prefix=/usr/local/ffmpeg --enable-gpl --enable-shared --enable-libx264
make clean
make && make install
export PATH=/usr/local/ffmpeg/bin:${PATH}
4.4 追加ffmpeg插件目录
vi /etc/ld.so.conf
/usr/local/x264/lib
sudo ldconfig
5. 测试视频压缩
ffmpeg -i rtsp://admin:12345@192.168.101.243 -c:a libfaac -ar 44100 -ab 48k -c:v libx264 -f flv rtmp://127.0.0.1:31935/live/video11