{"id":2114,"date":"2023-04-02T06:51:46","date_gmt":"2023-04-01T22:51:46","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=2114"},"modified":"2023-04-05T20:45:23","modified_gmt":"2023-04-05T12:45:23","slug":"nginx-rtmp-streaming-server-construction","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/04\/02\/nginx-rtmp-streaming-server-construction\/","title":{"rendered":"nginx-rtmp\u6d41\u5a92\u4f53\u670d\u52a1\u5668\u642d\u5efa"},"content":{"rendered":"<h3>\u4e0b\u8f7d\u5b89\u88c5 Nginx \u548c nginx-rtmp \u7f16\u8bd1\u4f9d\u8d56\u5de5\u5177<\/h3>\n<pre><code>sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev<\/code><\/pre>\n<p><!-- more --><\/p>\n<pre><code>yum -y install gcc gcc-c++ autoconf automake make\nyum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel<\/code><\/pre>\n<h3>\u4e0b\u8f7d Nginx \u548c nginx-rtmp\u6e90\u7801<\/h3>\n<pre><code>wget http:\/\/nginx.org\/download\/nginx-1.15.3.tar.gz\ngit clone https:\/\/github.com\/arut\/nginx-rtmp-module<\/code><\/pre>\n<h3>\u6dfb\u52a0 nginx-rtmp \u6a21\u5757\u7f16\u8bd1\u5230 Nginx<\/h3>\n<pre><code>tar -zxvf nginx-1.15.3.tar.gz\ncd nginx-1.15.3\n.\/configure --prefix=\/data\/server\/nginx --with-http_ssl_module --add-module=..\/nginx-rtmp-module\nmake\nmake install<\/code><\/pre>\n<h3>\u5b89\u88c5 Nginx Init \u811a\u672c\uff0c\u542f\u52a8\u548c\u505c\u6b62 Nginx \u670d\u52a1<\/h3>\n<pre><code>sudo wget https:\/\/raw.github.com\/JasonGiedymin\/nginx-init-ubuntu\/master\/nginx -O \/etc\/init.d\/nginx\nsudo chmod +x \/etc\/init.d\/nginx\nsudo update-rc.d nginx defaults\nsudo service nginx start\nsudo service nginx stop<\/code><\/pre>\n<h3>\u76f4\u63a5\u542f\u52a8\u548c\u505c\u6b62 Nginx \u670d\u52a1<\/h3>\n<pre><code>\/data\/server\/nginx\/sbin\/nginx  \/\/\u542f\u52a8Nginx\n\/data\/server\/nginx\/sbin\/nginx -s reload  \/\/\u4fee\u6539\u914d\u7f6e\u540e\u91cd\u65b0\u52a0\u8f7d\u751f\u6548 \/data\/server\/nginx\/sbin\/nginx -s reopen  \/\/\u91cd\u65b0\u6253\u5f00\u65e5\u5fd7\u6587\u4ef6\n\n\/data\/server\/nginx\/sbin\/nginx -s stop  \/\/\u5feb\u901f\u505c\u6b62Nginx\n\/data\/server\/nginx\/sbin\/nginx -s quit  \/\/\u5b8c\u6574\u6709\u5e8f\u7684\u505c\u6b62Nginx\n\n# killall nginx  \/\/\u6740\u6b7b\u5168\u90e8Nginx\u8fdb\u7a0b\n# ps -ef | grep nginx \u6216 ps aux | grep Nginx\n# kill -QUIT \u4e3b\u8fdb\u7a0b\u53f7  \/\/\u4ece\u5bb9\u505c\u6b62Nginx\n# kill -TERM \u4e3b\u8fdb\u7a0b\u53f7  \/\/\u5feb\u901f\u505c\u6b62Nginx\n# kill -9 \u4e3b\u8fdb\u7a0b\u53f7  \/\/\u5f3a\u5236\u505c\u6b62Nginx<\/code><\/pre>\n<h3>\u5b89\u88c5 FFmpeg<\/h3>\n<pre><code>.\/configure --disable-yasm --prefix=\/usr\/local\/ffmpeg\nmake\nmake install<\/code><\/pre>\n<pre><code># ln -s \/usr\/local\/ffmpeg\/bin\/ffmpeg \/usr\/ffmpeg\n# ffmpeg -version\nffmpeg version 2.8.8 Copyright (c) 2000-2016 the FFmpeg developers\nbuilt with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)\nconfiguration: --disable-yasm --prefix=\/usr\/local\/ffmpeg\nlibavutil      54. 31.100 \/ 54. 31.100\nlibavcodec     56. 60.100 \/ 56. 60.100\nlibavformat    56. 40.101 \/ 56. 40.101\nlibavdevice    56.  4.100 \/ 56.  4.100\nlibavfilter     5. 40.101 \/  5. 40.101\nlibswscale      3.  1.101 \/  3.  1.101\nlibswresample   1.  2.101 \/  1.  2.101<\/code><\/pre>\n<h3>\u914d\u7f6e nginx-rtmp \u670d\u52a1\u5668<\/h3>\n<p>\u6253\u5f00 \/data\/server\/nginx\/conf\/nginx.conf\uff0c\u5728\u672b\u5c3e\u6dfb\u52a0\u5982\u4e0b<\/p>\n<pre><code>rtmp {\n    server {\n        listen 88;\n        chunk_size 4096;\n\n        application live {\n            live on;\n            record off;\n            exec \/usr\/local\/ffmpeg\/bin\/ffmpeg -i rtmp:\/\/localhost\/live\/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp:\/\/localhost\/live360p\/$name;\n        }\n        application live360p {\n            live on;\n            record off;\n        }\n    }\n}<\/code><\/pre>\n<p>\u4fdd\u5b58\u914d\u7f6e\u6587\u4ef6\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8 Nginx \u670d\u52a1<\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u5982\u679c\u4f7f\u7528\u4e86\u9632\u706b\u5899\uff0c\u8bf7\u5141\u8bb8\u7aef\u53e3 tcp 1935<\/p>\n<\/blockquote>\n<h3>\u5ba2\u6237\u7aef\u4f7f\u7528 rtmp\u534f\u8bae\u8fdb\u884c\u89c6\u9891\u5b9e\u65f6\u91c7\u96c6<\/h3>\n<h4>\u63a8\u6d41<\/h4>\n<p>\u63a8\u6d41\u5730\u5740\uff1artmp:\/\/www.yezhou.me:8888\/live\/yezhou<\/p>\n<p>Field 1: rtmp:\/\/your.vultr.ip\/live\/<\/p>\n<p>Field 2: stream-key-your-set<\/p>\n<h4>\u62c9\u6d41<\/h4>\n<p>\u4f7f\u7528\u7f51\u9875Flash\u64ad\u653e\u5668\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/www.yezhou.me\/live\/\">http:\/\/www.yezhou.me\/live\/<\/a><\/p>\n<p>\u4f7f\u7528ffplay\u64ad\u653eRTMP\u76f4\u64ad\u6d41\uff1affplay rtmp:\/\/www.yezhou.me:8888\/live\/yezhou<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\u5b89\u88c5 Nginx \u548c nginx-rtmp \u7f16\u8bd1\u4f9d\u8d56\u5de5\u5177 sudo apt-get install bui [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[534],"tags":[538],"class_list":["post-2114","post","type-post","status-publish","format-standard","hentry","category-android-audio-video","tag-rtmp"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2114","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2114"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/2114\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}