欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ffmpeg编译硬转码

程序员文章站 2022-03-07 20:14:19
ffmpeg4.2.2编译+ubuntu18.02--prefix=/home/firefly/work/soft/install_ffmpeg4.2.2 --pkg-config-flags=--static --extra-cflags=-I/home/firefly/work/lib_build/include --extra-ldflags=-L/home/firefly/work/lib_build/lib --extra-libs='-lpthread -lm' --bindir=/home/...

ffmpeg4.2.2编译+ubuntu18.02


--prefix=/home/firefly/work/soft/install_ffmpeg4.2.2 --pkg-config-flags=--static --extra-cflags=-I/home/firefly/work/lib_build/include --extra-ldflags=-L/home/firefly/work/lib_build/lib --extra-libs='-lpthread -lm' --bindir=/home/server/bin --disable-shared --disable-ffplay --enable-ffmpeg --enable-pthreads --enable-static --enable-swscale --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --disable-libopus --disable-libvorbis --enable-libvpx --enable-libx264 --enable-pic --enable-nonfree 

1、ERROR: libfdk_aac not found
wget https://downloads.sourceforge.net/opencore-amr/fdk-aac-2.0.1.tar.gz
./configure --prefix=/home/firefly/work/lib_build/
make && make install
2、报错:ERROR: libmp3lame >= 3.98.3 not found
wget https://nchc.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
./configure --prefix=/home/firefly/work/lib_build/
make && make install
3、libvpx enabled but no supported decoders found
https://codeload.github.com/webmproject/libvpx/tar.gz/v1.8.2 网页下载
./configure --prefix=/home/firefly/work/lib_build/
make && make install
4、ERROR: libx264 not found
git clone https://code.videolan.org/videolan/x264.git
./configure --prefix=/home/firefly/work/lib_build/
4.1 Minimum version is nasm-2.13
https://www.nasm.us/pub/nasm/releasebuilds/2.13/
./configure --prefix=/home/firefly/work/lib_build/
make && make install
export PATH=/home/firefly/work/lib_build/bin:$PATH
make && make install

 

(2)瑞星微3299+ubuntu18编译

在以上基础上添加

5、log中显示没有libass

 git clone https://github.com/libass/libass.git

./autogen.sh

./configure 

make && make install

5.1 configure: error: Package requirements (fribidi >= 0.19.0) were not met:

     git clone https://github.com/libass/libass.git    

     ./autogen.sh

     ./configure 

     make && make install
二、编译显卡
1、lspci | grep VGA
sudo vim /etc/modprobe.d/blacklist.conf
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb
sudo update-initramfs -u
sudo apt-get install make //目前使用4.1版本
sudo reboot

sudo ./NVIDIA-Linux-x86_64-440.82.run 
sudo ./cuda_10.2.89_440.33.01_linux.run
2、--prefix=/home/firefly/work/soft/install_ffmpeg4.2.2 --pkg-config-flags=--static --extra-cflags=‘-I/home/firefly/work/lib_build/include -I/usr/local/cuda/include’ --extra-ldflags=‘-L/home/firefly/work/lib_build/lib -L/usr/local/cuda/lib64’ --extra-libs='-lpthread -lm' --disable-shared --enable-ffplay --enable-ffmpeg --enable-pthreads --enable-static --enable-swscale --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --disable-libopus --disable-libvorbis --enable-libvpx --enable-libx264 --enable-pic --enable-nonfree --enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp
make
3、ERROR: cuvid requested, but not all dependencies are satisfied: ffnvcodec 
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

// 查看硬解码器
ffmpeg -codecs | grep cuvid

// 查看硬编码器
ffmpeg -codecs | grep nvenc

三、硬件转码
./bin/ffmpeg -hwaccel cuvid -c:v mpeg4_cuvid -i ribuluo.mp4 -c:v h264_nvenc -b:v 2048k -vf scale_npp=1280:-1 -r 29.97 -ab 128000 -ar 44100 -y out.mp4 //视频mpeg4编码
-hwaccel cuvid:指定使用cuvid硬件加速
-c:v mpeg4_cuvid:使用mpeg4进行视频解码
-c:v h264_cuvid:使用h264_cuvid进行视频解码
-c:v h264_nvenc:使用h264_nvenc进行视频编码
-vf scale_npp=1280:-1:指定输出视频的宽高,高-1代表按照比例自动适应
-b:v:指定输出视频的码率,即输出视频每秒的bit数
-ab bitrate 设置音频码率 (128000)
-ar freq 设置音频采样率(16000)

四、视频文件的编码格式 
H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 ——》h264
MPEG-4 part 2 ——》mpeg4

五、ffmpeg使用需要安装指令
sudo apt-get install libsdl2-2.0
sudo apt-get install libsdl2-dev
 

 

本文地址:https://blog.csdn.net/m0_37092540/article/details/107242672