主要包括如下三个部分安装:

1. Nginx-rtmp模块:PingOS安装

使用docker进行安装:reference

# 拉取dockerfile
git clone https://github.com/pingostack/pingos.git
cd docker
# 使用shell脚本产生docker容器(默认为docker_pingos_1)
chmod +x run.sh
./run.sh build
。/run.sh up -d

2. 本地安装H264 H265

按照ffmpeg官网指南安装H264 H265

# 安装需要的库
sudo apt-get update -qq && sudo apt-get -y install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libgnutls28-dev \
  libsdl2-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  meson \
  ninja-build \
  pkg-config \
  texinfo \
  wget \
  yasm \
  zlib1g-dev

# 安装h264 h265
sudo apt-get install libx264-dev
sudo apt-get install libx265-dev libnuma-dev

3. 本地安装ffmpeg

错误情况参考 reference

## 安装金山云的ffmpeg 3.4版本
git clone https://github.com/ksvc/FFmpeg.git
cd FFmpeg
git reset --hard origin/release/3.4
# 编译
./configure --enable-static --enable-pic \
        --disable-encoders --enable-encoder=aac --enable-encoder=libx264 --enable-gpl --enable-libx264 --enable-encoder=libx265  --enable-libx265 \
        --disable-decoders --enable-decoder=aac --enable-decoder=h264 --enable-decoder=hevc  \
        --disable-demuxers --enable-demuxer=aac --enable-demuxer=mov --enable-demuxer=mpegts --enable-demuxer=flv --enable-demuxer=h264 --enable-demuxer=hevc --enable-demuxer=hls  \
        --disable-muxers --enable-muxer=h264  --enable-muxer=flv --enable-muxer=f4v  --enable-muxer=mp4 \
        --disable-doc --extra-cflags="-fno-stack-check"
make -j8

### libavcodec/libx264.c:282:9: error: ‘x264_bit_depth’ undeclared (first use in this function)
### 会出现类似报错,需要修改 libavcodec/libx264.c
### 这里用vim指令讲所有x264_bit_depth替换成X264_BIT_DEPTH
vim ./libavcodec/libx264.c
:%s/x264_bit_depth/X264_BIT_DEPTH/g
### 再回到编译部分,重新configure和make

4.测试

cd FFmpeg
# 推流
./ffmpeg -re -i ./video.mp4 -c:a copy -c:v libx265 -f flv rtmp://127.0.0.1/live/h265
# 接流
./ffplay rtmp://127.0.0.1/live/h265

如果一切顺利,那么你将在屏幕上看到你推流的本地视频!

03-05 23:30