1. Prepare raspberry PI board and system
If you have a raspberrypi 3B or 4B in your hand and have installed the official raspberrypi 32bit OS, it is highly recommended to use the latest raspberrypi 4B+, because a 4B gigabit card is true gigabit.
Install video capture and codec related applications and dependencies
2.1 compile installation dependent libraries NASM distfiles.macports.org/nasm
# sudo wget HTTP: / / http://distfiles.macports.org/nasm/nasm-2.14.tar.bz2
# sudo tar -vxzf nasm-2.14.tar.bz2
# CD nasm - 2.14
# sudo ./configure && sudo make && sudo make install
Copy the code
2.2 compiler installed x264 source address www.videolan.org/developers/… This library is used to support x264 encoding hardware acceleration without software FFMPEG encoding can only pass -VCOdec H264 parameters for soft coding, but can not pass -VCOdec H264_OMX to obtain hardware acceleration
The disable-ASM parameter indicates that the nasM library installed in the previous step will be used
# git clone https://code.videolan.org/videolan/x264.git
# cd x264
/configure --prefix=$PWD/_install --enable-static --disable-asm --disable-opencl -- enable-shared
# sudo make && sudo make install
# sudo cp _install/include /usr/ -rf
# sudo cp _install/lib /usr/ -rf
Copy the code
Three, source install FFMPEG (start over)
Official website to download address: www.ffmpeg.org/download.ht… The latest version is 4.3
# sudo apt-get install libomxil-bellagio-dev libpcre3-dev libssl-dev zlib1g zlib1g
# sudo wget HTTP: / / http://www.ffmpeg.org/releases/ffmpeg-4.3.tar.gz
# sudo tar -vxzf ffmPEG-4.3.tar. gz
# CD ffmpeg - 4.3
# sudo ./configure --prefix=$PWD/_install --enable-shared --enable-gpl --enable-libx264 --enable-omx-rpi --enable-mmal --enable-hwaccel=h264_mmal --enable-decoder=h264_mmal --enable-encoder=h264_omx --enable-omx
# sudo make && sudo make install
# sudo cp _install/include /usr/ -rf
# sudo cp _install/lib /usr/ -rf
# sudo cp _install/bin /usr/ -rf
# ffmpeg -v
Copy the code
4.1 download nginx – source download backup with RTMP module, behind will install nginx compiled reference # sudo git clone https://github.com/arut/nginx-rtmp-module.git
4.2 Compiling and Installing nginx
# sudo wget HTTP: / / http://nginx.org/download/nginx-1.14.2.tar.gz
# CD nginx - 1.14.2
# sudo ./configure --prefix=/usr/local/nginx --add-module=.. /nginx-rtmp-module --with-http_ssl_module
# sudo make && sudo make install
Copy the code
4.3 After the installation, create a local video stream file cache directory. Nginx will use this cache during stream pushing. In this example, the directory is /data/ HLS
The nginx configuration example directly overwrites the entire nginx.conf content with this section, and then changes the nginx.conf as needed
user pi;
worker_processes auto;
events {
worker_connections 1024;
}
http {
server {
listen 9080;
location / {
root html;
index index.html index.htm;
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xls;
}
location /stat.xls {
root /data/git/nginx-rtmp-module;
}
}
}
rtmp {
Local push server configuration, receive and then forward to the external network push service
server {
listen 1935;
chunk_size 4000;
application hls {
live on;
hls on;
Create a local file cache directory
hls_path /data/hls;
hls_fragment 10s;
# Your own stream addresspush rtmp://livepush.walkye.com/live/demo2?txSecret=62cab0d2dba54331d1af2bd6b3d69d21&txTime=5F0570A6; }}}Copy the code
Then start nginx # sudo/usr/local/nginx/sbin/nginx