FFmpeg学习

0

FFmpeg安装

# apt安装
sudo apt install ffmpeg

# 源码安装
# nasm
cd /data/dev
wget https://www.nasm.us/pub/nasm/releasebuilds/2.16/nasm-2.16.tar.gz
tar -zxvf nasm-2.16.tar.gz
cd nasm-2.16/
./configure
sudo make -j 8 && sudo make install

# yasm
cd /data/dev
wget https://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
sudo make -j 8 && sudo make install

# libvpx?  --enable-gpl --enable-libvpx
cd /data/dev
#git clone https://chromium.googlesource.com/webm/libvpx.git
git clone https://github.com/webmproject/libvpx.git
cd libvpx/
git checkout v1.13.0
./configure --enable-static --enable-shared --enable-vp8 --enable-vp9 --enable-vp9-highbitdepth --as=yasm --disable-examples --disable-unit-tests
sudo make -j 8 && sudo make install

# libopus? --enable-gpl --enable-libopus
cd /data/dev
wget https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
tar -zxvf opus-1.3.1.tar.gz
cd opus-1.3.1/
./configure --enable-static --enable-shared
sudo make -j 8 && sudo make install

# libx264? --enable-gpl --enable-libx264
cd /data/dev
git clone https://code.videolan.org/videolan/x264.git
cd x264/
./configure --enable-static --enable-shared
sudo make -j 8 && sudo make install

# libx265? --enable-gpl --enable-libx265
cd /data/dev
git clone https://bitbucket.org/multicoreware/x265_git
cd x265_git/
git checkout 3.5
cd build/linux/
cmake -G "Unix Makefiles" ../../source/
sudo make -j 8 && sudo make install

# libopenh264? --enable-gpl --enable-libopenh264
cd /data/dev
git clone https://github.com/cisco/openh264.git
cd openh264/
git checkout v2.4.1
sudo make -j 8 && sudo make install

# ffmpeg
cd /data/dev
wget http://www.ffmpeg.org/releases/ffmpeg-5.1.3.tar.xz
tar -Jxvf ffmpeg-5.1.3.tar.xz
cd ffmpeg-5.1.3/
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
./configure          \
--enable-static      \
--enable-shared      \
--enable-gpl         \
--enable-libvpx      \
--enable-libopus     \
--enable-libx264     \
--enable-libx265     \
--enable-libopenh264 \
--enable-encoder=libvpx_vp8 --enable-decoder=vp8 --enable-parser=vp8 \
--enable-encoder=libvpx_vp9 --enable-decoder=vp9 --enable-parser=vp9
sudo make -j 8 && sudo make install

sudo vim /etc/ld.so.conf

---
/usr/local/lib/
---

ldconfig

# 查看版本
ffmpeg -version
# 查看编解码
ffmpeg -codecs
# 格式化文件
ffmpeg -y -i source.mkv -c copy target.mp4
# 查看文件格式
ffprobe -v error -show_streams -print_format json source.mp4

GPU安装

驱动
# cuda
https://developer.nvidia.com/cuda-downloads
# nv-codec-headers
https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
# 验证
nvidia-smi

编译提示ERROR: openh264 not found using pkg-config

apt install pkg-config