1. Prepare the environment
- Install the operating system Cenos
- Configure yum source
yum: https://developer.aliyun.com/mirror/- Nginx依赖
gcc-c++ zlib pcre openssl openssl-devel- Nginx and expansion modules
Nginx itself is just a server, streaming media and do not support, so we have to download the corresponding modules to extend its functionality
MP4 module: http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7. tar.gz
FLV module: http://sourceforge.net/projects/yamdi/files/yamdi/yamdi-1.9.tar.gz
live streaming module: https://github.com/adwpc/nginx-rtmp-module
FastDFS module : https://github.com/happyfish100/fastdfs-nginx-module- FFMPEG
ffmpeg :https://ffmpeg.zeranoe.com/builds/- OBS plug flow
- EV pull flow
2. Installation Environment
2.1 upload all modules to the system
mkdir /opt/nginx
cd /opt/nginx
rz nginx-1.8.1.tar.gz
rz nginx_mod_h264_streaming-2.2.7.tar.gz
rz yamdi-1.9.tar.gz
rz nginx-rtmp-module-master.zip
2.2 Installation FLV module
tar -zxvf yamdi-1.9.tar.gz
cd yamdi
./configure
mark && make install
2.3 MP4 decompression module
tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
processing a bugs
CD / opt / Nginx / nginx_mod_h264_streaming / the src
comment row 157 lines -161
/* TODO: Win32 */
// if (r->zero_in_uri)
// {
// return NGX_DECLINED;
// }
2.4 decompression nginx
tar -zxvf nginx-1.8.1.tar.gz
tar -zxvf nginx_mod_h264_streaming.tar.gz
unzip nginx-rtmp-module-master.zip
2.5 and adding module mounting nginx
./configure --add-module = .. / nginx_mod_h264_streaming --add-module = .. / nginx-rtmp-module-master --with-http_ssl_module --prefix = / opt / software / nginx --with-http_flv_module - -with-http_stub_status_module
NOTE: If the compiler error, vim objs / Makefile (modified objs / Makefile file, remove one of the "-Werror"), then the normal build.
2.6 Play Configuration
cd /opt/software/nginx/conf
vim nginx.conf
Add support for FLV and MP4 are
location ~ \.flv {
flv;
}
location ~ \.mp4$ {
mp4;
}
2.7 FFmpeg
FFmpeg is a record that can be used, converting the digital audio, video, and can open it into a computer program stream
upload
rz ffmpeg-4.2.2.tar.bz2
installation
yum install bzip2 # as a suffix to install bz2 bzip2
tar -jxvf use ffmpeg-4.2.2.tar.bz2 # -jxvf decompression bz2 file
cd ffmpeg-4.2.2 # to enter the directory
./configure --prefix = / opt / software / ffmpeg # configuration settings installation path
make && make install # install
3. Demand
MP4 upload test
cd /opt/software/nginx/html
rz test.mp4
View http://192.168.3.9/test.mp4
4. Live
4.1 Configuration Service
cd /opt/software/nginx/conf
vim nginx.conf
rtmp {
server {
listen 1935; #监听的端口
chunk_size 4096;
application hls { #rtmp推流请求路径
live on;
hls on;
hls_path /opt/software/nginx/html/hls;
hls_fragment 5s;
}
}
}
mkdir /opt/software/nginx/html/hls
4.2 Live Streaming
Setting the Scene
Add video scene capture device, a display window capture or capture
NOTE: Solutions window black
Device Manager -> Display Adapter -> graphics card - Disable
Setting plug-flow address
rtmp server: rtmp: //192.168.3.9: 1935 / HLS /
Key: 12345
4.3 pull live stream
EV borrow player
input pull-stream address
rtmp address: rtmp: //192.168.3.9: 1935 / HLS / 12345
Click Start Watch live