Set up a Streaming Media Server in nginx and an nginx Streaming Media Server
1. Install the PCRE Library
Download pcre-8.37.tar.gz at www.pcre.org.
Tar-zxvf pcre-8.37.tar.gz
Cd pcre-8.37
./Configure
Make
Make install
2. Install the zlib library
Download zlib-1.2.8.tar.gz at www.zlib.net.
Tar-zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./Configure
Make
Make install
3. Install SSL
Download openssl-1.0.2g.tar.gz to www.openssl.org.
Tar-zxvf openssl-1.0.2g.tar.gz
./Config
Make
Make install
4. Download nginx from nginx.org
Download To https://github.com/arut/nginx-rtmp-module: nginx-rtmp-module
Extract
Enter the decompressed nginx
Run the following commands in sequence:
./Configure -- prefix = "installation directory" -- add-module = "nginx-rtmp-module decompressed path" -- with-http_ssl_module
Make-f objs/Makefile
Make-f objs/Makefile install
5. Configuration
# Streaming configuration, same as http configuration
Rtmp {
Server {
Listen 2017;
Publish_time_fix on;
Application live {
Live on;
Allow publish all;
Allow play all;
}
# Used for HLS stream pulling
Application vod {
Live on;
Hls on;
Hls_path "streaming directory ";
Hls_fragment 5S;
}
# Used for RTMP stream pulling
Application app {
Live on;
# Record all;
# Record_path/alidata/server/nginx/www;
}
}
# Stream pulling configuration, same to the server under http
Server {
Listen 8080;
Location /{
Types {
Application/vnd. apple. mpegurl m3u8;
Video/mp2t ts;
}
Root "streaming directory ";
Add_header Cache-Control no-cache;
}
}
6. Key html stream pulling code
// HLS stream pulling
<Video controls autoplay>
<Source src = "http: // 192.168.1.104: 8080/qq. m3u8" type = "application/vnd. apple. mpegurl"/>
<P class = "warning"> Your browser does not support HTML5 video. </p>
</Video>
// The RTMP stream pulling and streaming URL are consistent
Rtmp: // 192.168.1.104: 2017/app/qq
7. Install ffmpeg streaming simulation tool
Download the compressed package from http://ffmpeg.org/official website and decompress it
Tar-xjvf ffmpeg-3.3.1.tar.bz2
Download yasmand decompress yasmat http://yasm.tortall.net/download.html.
Tar-xvzf yasm-1.3.0.tar.gz
Cd yasm-1.3.0/
./Configure
Make
Make install
Enter the decompressed ffmpeg
./Configure -- enable-shared -- prefix =/monchickey/ffmpeg
Make
Make install
Vim/etc/ld. so. conf. d/ffmpeg. conf
Add a line of content:/monchickey/ffmpeg/lib, save and exit, and then execute ldconfig to make the configuration take effect.
Then cd/monchickey/ffmpeg/check the version./ffmpeg-version is normal.
For convenience, you can add the ffmpeg command to the PATH in the/etc/profile file.
Sudo vim/etc/profile
Locate the export row and add
Export PATH =/usr/local/ffmpeg/bin/: $ PATH
Save and run
Source/etc/profile
8. Simulate streaming
Ffmpeg-re-I aaa.mp4-c copy-f flv rtmp: // 192.168.1.104: 2017/vod/qq
9. Reference URL
Https://www.cnblogs.com/qazwsxwtc/p/5384967.html
Https://www.cnblogs.com/freeweb/p/6897907.html
Http://blog.csdn.net/enweitech/article/details/52485535
Https://github.com/arut/nginx-rtmp-module
Http://blog.csdn.net/redstarofsleep/article/details/45092147
Http://www.360doc.com/content/15/0618/10/597197_478933808.shtml