之所以编译ffmpeg,是因为需要做编码的转换,而yum安装的没有预编译这些库,所以参照这里编译安装。
https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
源码包说明
ffmpeg
官网地址http://ffmpeg.org/
一个完整的跨平台解决方案,用于录制,转换和流式传输音频和视频。
wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz2
ffmpegnasm
官网地址https://www.nasm.us/
nasm使用在windows、linux等系统下的汇编。
nasm下载
wgethttps://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
Yasm
某些库使用的汇编程序
http://www.tortall.net/projects/yasm/releases/
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
yasmH.264
下载地址
http://download.videolan.org/x264/snapshots/last_stable_x264.tar.bz2
wgethttp://download.videolan.org/x264/snapshots/last_stable_x264.tar.bz2
H264H.265
下载地址
https://bitbucket.org/multicoreware/x265/downloads/
H265 H265拒绝访问,所以直接在win 上下载,然后ftp 上传。
ftplibfdk_aac
下载地址
https://github.com/mstorsjo/fdk-aac
fdk-aaclibmp3lame
MP3音频编码器
https://sourceforge.net/projects/lame/files/lame/3.100/
wgethttps://nchc.dl.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
libmp3lamelibopus
Opus音频解码器和编码器
https://archive.mozilla.org/pub/opus/
wgethttps://archive.mozilla.org/pub/opus/opus-1.3.tar.gz
libopuslibogg
Ogg比特流库
https://ftp.osuosl.org/pub/xiph/releases/ogg/
wgethttps://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz
libogglibvorbis
Vorbis audio encoder
Vorbis音频编码器
wgethttps://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz
https://ftp.osuosl.org/pub/xiph/releases/vorbis/
libvorbislibvpx
VP8 / VP9视频编码器和解码器
https://github.com/webmproject/libvpx.git
git clone --depth 1https://github.com/webmproject/libvpx.git
libvpx统一源码包
先前已经创建了文件夹ffmpeg_sources,将源码包复制到该目录下
ffmpeg_sources注意这里少了一个yasm-1.3.0.tar.gz
安装依赖
yum install autoconf automake bzip2 cmakefreetype-devel gcc gcc-c++ git libtool make mercurial pkgconfig zlib-devel
x265 需要mercurialcmake cmake-curses-gui build-essential yasm
yum
编译安装
按照如下顺序编译安装:
Nasm
tar xjvf nasm-2.14.02.tar.bz2 ./autogen.sh ./configure --prefix="$HOME/ffmpeg_build"--bindir="$HOME/bin" make make installyasm
tar xzvf yasm-1.3.0.tar.gz
cd yasm-1.3.0 ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" make make installX264
tar jxvf last_stable_x264.tar.bz2
cd x264-snapshot-20190115-2245-stable/ PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"./configure --prefix="$HOME/ffmpeg_build"--bindir="$HOME/bin" --enable-static make make installX265
tar zxvf x265_2.9.tar.gz
Cd ./x265_2.9/build/linux Cd ./x265_2.9/build/linux cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off ../../source make make installlibfdk-aac
Cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make installlame
tar zxvf lame-3.100.tar.gz ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm make make installopus
tar zxvf opus-1.3.tar.gz ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make installlibogg
Ogg bitstream library. Required by libvorbis.
./configure --prefix="$HOME/ffmpeg_build" --disable-shared make && make installlibvorbis
./configure --prefix="$HOME/ffmpeg_build" --with-ogg="$HOME/ffmpeg_build" --disable-shared make && make installlibvpx
./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm make && make installffmpeg
tar xjvf ffmpeg-snapshot.tar.bz2PATH="$HOME/bin:$PATH"PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--extra-cflags="-I$HOME/ffmpeg_build/include" \
--extra-ldflags="-L$HOME/ffmpeg_build/lib" \
--extra-libs=-lpthread \
--extra-libs=-lm \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
freetype2 not found yum install freetype2 yum install freetype* pkg-config --list-all 发现存在参照网上示例:
https://yq.aliyun.com/ziliao/516130
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"./configure \
--prefix="$HOME/ffmpeg_build" \
--pkg-config-flags="--static" \
--bindir="$HOME/bin" \
--enable-gpl \
--enable-libfdk_aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-nonfree
error 所以,直接试下make发现可以编译 hash -r ok初步验证
提供Ffmpeg服务的box机子网络为私有网络;
提供rtsp->rtmp转码服务的box机子网络为私有网络:该box同时提供nginx服务和NAT(80->80、1935->1935)的服务;
NAT以上box宿主机IP均为192.168.2.251。
大华摄像头IP为192.168.2.239
启动两个box,使用ffmpeg去捕捉信息:
ffmpeg -rtsp_transport tcp -i "rtsp://admin:a1234567@192.168.2.239:554/cam/realmonitor?channel=1&subtype=1" -ar 44100 -ac 1 -f flv"rtmp://192.168.2.251:1935/hls/itc"
ffmpeg top stat vlc player Ctrl+c初步验证可用,至于其它功能验证,后续补充。
网友评论