{"id":1458,"date":"2021-01-16T19:49:30","date_gmt":"2021-01-16T11:49:30","guid":{"rendered":"http:\/\/123.57.164.21\/?p=1458"},"modified":"2021-02-27T14:30:38","modified_gmt":"2021-02-27T06:30:38","slug":"%e9%80%9a%e8%bf%87-nginx-%e6%90%ad%e5%bb%ba%e4%b8%80%e4%b8%aa%e5%9f%ba%e4%ba%8e-http-flv-%e7%9a%84%e7%9b%b4%e6%92%ad%e6%b5%81%e5%aa%92%e4%bd%93%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=1458","title":{"rendered":"\u901a\u8fc7 nginx \u642d\u5efa\u4e00\u4e2a\u57fa\u4e8e http-flv \u7684\u76f4\u64ad\u6d41\u5a92\u4f53\u670d\u52a1\u5668"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">\u524d\u7f6e\u77e5\u8bc6<\/h4>\n\n\n\n<p>\u5728\u642d\u5efa\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u76f4\u64ad\u8fd9\u4e2a\u6982\u5ff5\u672c\u8eab\u6709\u4e00\u4e2a\u5927\u6982\u7684\u7406\u89e3\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7ecf\u5e38\u542c\u5230\u4e24\u4e2a\u8bcd\uff1a<strong>\u63a8\u6d41(push\/upstream)<\/strong>&nbsp;\u548c&nbsp;<strong>\u62c9\u6d41(pull\/downstream)<\/strong><\/p>\n\n\n\n<p><strong>\u63a8\u6d41<\/strong>\u5927\u6982\u6307\u7684\u662f\u5c06\u4ece\u67d0\u8bbe\u5907\u4e0a\u91c7\u96c6\u5230\u7684\u753b\u9762\u3001\u97f3\u9891\u4e0a\u4f20\u5230\u76f4\u64ad\u6d41\u5a92\u4f53\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n\n\n\n<p><strong>\u62c9\u6d41<\/strong>\u5927\u6982\u6307\u7684\u662f\u4ece\u76f4\u64ad\u6d41\u5a92\u4f53\u670d\u52a1\u5668\u4e0a\u4e0b\u8f7d\u90a3\u4e9b\u63a8\u6d41\u4e0a\u6765\u7684\u4e1c\u897f\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"433\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/01\/image-34-1024x433.png\" alt=\"\" class=\"wp-image-1461\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-1024x433.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-300x127.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-768x324.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-830x351.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-230x97.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-350x148.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34-480x203.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-34.png 1212w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u4fe1\u606f\u5728\u7f51\u7edc\u4e2d\u4f20\u64ad\u4e00\u5b9a\u8981\u9075\u5faa\u67d0\u79cd\u534f\u8bae\uff0c\u5426\u5219\u5c31\u4e71\u5957\u4e86\u561b\uff0c\u90a3\u4e48\u8fd9\u4e9b\u6240\u8c13\u7684&nbsp;<strong>\u6d41<\/strong>&nbsp;\u5728\u7f51\u7edc\u4e2d\u4f20\u64ad\uff0c\u53c8\u6709\u54ea\u4e9b\u53ef\u4ee5\u9075\u5faa\u7684\u534f\u8bae\u5462\uff1f\u5927\u6982\u5217\u4e3e\u6211\u8ba4\u8bc6\u76843\u4e2a\uff1a<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"rtmp\">RTMP<\/h4>\n\n\n\n<p>RTMP \u534f\u8bae\u662f Adobe \u516c\u53f8\u8bbe\u8ba1\u7684\u4e00\u4e2a\u57fa\u4e8e&nbsp;<code>TCP<\/code>&nbsp;\u4f20\u8f93\u7684\u534f\u8bae\uff0c\u88ab\u8bbe\u8ba1\u7528\u6765\u5bf9\u57fa\u4e8e\u5e95\u5c42\u4f20\u8f93\u534f\u8bae\u7684\u591a\u5a92\u4f53\u4f20\u8f93\u6d41\uff08\u5982\u97f3\u9891\u3001\u89c6\u9891\u548c\u4ea4\u4e92\u6570\u636e\uff09\u8fdb\u884c\u590d\u7528\u548c\u5206\u5305\u3002<\/p>\n\n\n\n<p>RTMP \u534f\u8bae\u662f\u76ee\u524d\u6700\u4e3b\u6d41\u7684\u4f20\u8f93\u534f\u8bae\uff0c\u4f46\u662f\u5b83\u6700\u5927\u7684\u95ee\u9898\u662f\uff0c\u5982\u679c\u9700\u8981\u5728\u6d4f\u89c8\u5668\u4e0a\u8fdb\u884c\u62c9\u6d41\uff0c\u90a3\u4e48\u6d4f\u89c8\u5668\u672c\u8eab\u9700\u8981\u652f\u6301&nbsp;<strong>flash<\/strong>\uff0c\u800c\u5f53\u524d\u4f17\u591a\u6d4f\u89c8\u5668\u5382\u5546\u5df2\u7ecf\u9ed8\u8ba4\u7981\u7528\u4e86flash\uff0c\u5bf9\u4e8e\u7528\u6237\u4f53\u9a8c\u5341\u5206\u4e0d\u53cb\u597d\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"http-flv\">HTTP-FLV<\/h4>\n\n\n\n<p><strong>flv(flash video)<\/strong>&nbsp;\u672c\u8eab\u662f\u4e00\u79cd\u89c6\u9891\u683c\u5f0f\uff0c\u4e5f\u662f Adobe \u516c\u53f8\u63a8\u51fa\u7684\uff0c\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u7684\u89c6\u9891\u5927\u591a\u90fd\u662f\u4ee5\u8fd9\u79cd\u683c\u5f0f\u5c01\u88c5\u7684\u3002\u800c&nbsp;<strong>http-flv<\/strong>&nbsp;\u5219\u662f\u5c06\u63a8\u6d41\u63a8\u4e0a\u6765\u7684\u6d41\u5a92\u4f53\u6570\u636e\u5c01\u88c5\u6210&nbsp;<strong>flv<\/strong>&nbsp;\uff0c\u5e76\u4e14\u901a\u8fc7&nbsp;<code>HTTP<\/code>&nbsp;\u534f\u8bae\u8fdb\u884c\u4f20\u8f93\u7684\u534f\u8bae\u3002\u9700\u8981\u6d4f\u89c8\u5668\u7aef\u652f\u6301\u64ad\u653e flv \u683c\u5f0f\u7684\u89c6\u9891\u624d\u53ef\u4ee5\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5728\u672c\u6587\u4e2d\uff0c\u63a8\u6d41\u4f7f\u7528\u7684\u534f\u8bae\u662f rtmp \uff0c\u800c\u62c9\u6d41\u65f6\u4f7f\u7528\u7684\u534f\u8bae\u662f http-flv\u3002<\/p><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"hls\">HLS<\/h4>\n\n\n\n<p><strong>HLS(Http Live Streaming)<\/strong>&nbsp;\u662f\u82f9\u679c\u63d0\u51fa\u7684\u57fa\u4e8e&nbsp;<code>HTTP<\/code>&nbsp;\u7684\u6d41\u5a92\u4f53\u4f20\u8f93\u534f\u8bae\uff0c\u4ed6\u7684\u5927\u81f4\u539f\u7406\u662f\u5c06\u4e00\u4e2a\u5927\u7684\u89c6\u9891\u6570\u636e\u6587\u4ef6\u5207\u5206\u6210\u82e5\u5e72\u4e2a\u5c0f\u7684\u89c6\u9891\u6587\u4ef6\uff0c\u7136\u540e\u5ba2\u6237\u7aef\u62c9\u6d41\u7684\u65f6\u5019\u4f9d\u7167\u987a\u5e8f\u4e00\u4e2a\u4e00\u4e2a\u5730\u5c06\u5c0f\u89c6\u9891\u6587\u4ef6\u62c9\u4e0b\u6765\u3002HLS\u6700\u5927\u7684\u4f18\u70b9\u5c31\u662f\uff0cHTML5\u53ef\u4ee5\u76f4\u63a5\u6253\u5f00\u64ad\u653e\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>nginx \u561b\uff0c\u4f17\u6240\u5468\u77e5\u5b83\u5728 Windows \u5e95\u4e0b\u6709\u5404\u79cd\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u6240\u4ee5\u6211\u4eec\u8fd9\u4e00\u6b21\u9009\u62e9\u5728&nbsp;<code>linux<\/code>&nbsp;\u5e95\u4e0b\u8fdb\u884c\u90e8\u7f72\u8fd9\u4e48\u4e00\u5957\u670d\u52a1\u5668\u3002<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>nginx \u561b\uff0c\u4f17\u6240\u5468\u77e5\u5b83\u5728 Windows \u5e95\u4e0b\u6709\u5404\u79cd\u5947\u5947\u602a\u602a\u7684\u95ee\u9898\uff0c\u6240\u4ee5\u6211\u4eec\u8fd9\u4e00\u6b21\u9009\u62e9\u5728&nbsp;<code>linux<\/code>&nbsp;\u5e95\u4e0b\u8fdb\u884c\u90e8\u7f72\u8fd9\u4e48\u4e00\u5957\u670d\u52a1\u5668\u3002<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5176\u5b9e\u6211\u5728\u90e8\u7f72\u8fd9\u4e2a\u670d\u52a1\u5668\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u7684\u662f docker \uff0c\u4f46\u662f\u672c\u6587\u5728\u8bb0\u5f55\u7684\u65f6\u5019\u4e0d\u6253\u7b97\u57fa\u4e8e docker \u73af\u5883\u8fdb\u884c\u89e3\u91ca\uff0c\u56e0\u4e3a\u4e2a\u4eba\u5bf9 docker \u8fd8\u6709\u5f88\u591a\u4e0d\u719f\u6089\u7684\u5730\u65b9\u3002<\/p><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u4e00\u3001\u4e0b\u8f7d\u6e90\u4ee3\u7801\">\u4e00\u3001\u4e0b\u8f7d\u6e90\u4ee3\u7801<\/h4>\n\n\n\n<p>\u4e3a\u4e86\u8ba9 nginx \u62e5\u6709\u5904\u7406\u6d41\u5a92\u4f53\u7684\u80fd\u529b\uff0c\u6211\u4eec\u9700\u8981\u901a\u8fc7&nbsp;<code>\u7f16\u8bd1\u5b89\u88c5<\/code>&nbsp;\u7684\u65b9\u5f0f\u6765\u5b89\u88c5 nginx\u3002<\/p>\n\n\n\n<p>\u7531\u4e8e\u5728\u672c\u7bc7\u4e2d\u6211\u4eec\u5c1d\u8bd5\u8bb2\u6e05\u695a\u7684\u662f\u642d\u5efa\u4e00\u4e2a\u57fa\u4e8e&nbsp;<code>http-flv<\/code>&nbsp;\u7684\u6d41\u5a92\u4f53\u670d\u52a1\u5668\uff0c\u6240\u4ee5\u5728\u7f16\u8bd1\u65f6\uff0c\u6211\u4eec\u9700\u8981\u4e3a nginx \u6dfb\u52a0&nbsp;<a href=\"https:\/\/github.com\/winshining\/nginx-http-flv-module\" target=\"_blank\" rel=\"noreferrer noopener\">nginx-http-flv-module<\/a>&nbsp;\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u628a&nbsp;<code>nginx<\/code>&nbsp;\u548c&nbsp;<code>nginx-http-flv-module<\/code>&nbsp;\u7684\u6e90\u4ee3\u7801\u90fd\u4e0b\u8f7d\u5230&nbsp;<code>\/tmp<\/code>&nbsp;\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>nginx<\/code>&nbsp;\u7248\u672c\u53f7\u76ee\u524d\u662f&nbsp;<code>1.15.9<\/code>\uff0c<code>nginx-http-flv-module<\/code>&nbsp;\u7684\u7248\u672c\u53f7\u76ee\u524d\u662f&nbsp;<code>1.2.6<\/code>\uff0c\u5728\u4e0b\u65b9\u7684\u547d\u4ee4\u884c\u4e2d\u53ef\u80fd\u6709\u6240\u4f53\u73b0\u3002<\/p><\/blockquote>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cd \/tmp\ngit clone nginx-http-flv-module\nwget https:\/\/nginx.org\/download\/nginx-1.15.9.tar.gz<\/pre>\n\n\n\n<p>\u89e3\u538b\u521a\u521a\u4e0b\u8f7d\u7684&nbsp;<code>nginx<\/code>\uff0c\u5e76\u8fdb\u5165\u5230 nginx \u7684\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tar -xzf nginx-1.15.9.tar.gz\ncd nginx-1.15.9\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e8c\u3001\u7f16\u8bd1\u5b89\u88c5<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/configure --add-module=\/tmp\/nginx-http-flv-module --with-http_ssl_module\nmake\nmake install\n<\/pre>\n\n\n\n<p>\u8fd9\u4e48\u4e00\u4e2a\u8fc7\u7a0b\u4e0b\u6765\u540e\uff0c<code>nginx<\/code>&nbsp;\u4f1a\u88ab\u5b89\u88c5\u5728&nbsp;<code>\/usr\/local\/nginx<\/code>&nbsp;\u5e95\u4e0b\u3002<\/p>\n\n\n\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>nginx-http-flv-module<\/code>&nbsp;\u662f\u57fa\u4e8e&nbsp;<code>nginx-rtmp-module<\/code>&nbsp;\u5f00\u53d1\u7684\uff0c\u5b8c\u5168\u517c\u5bb9&nbsp;<code>nginx-rtmp-module<\/code>&nbsp;\u7684\u6240\u6709\u529f\u80fd\uff0c\u6240\u4ee5<strong>\u5728\u7f16\u8bd1\u65f6\u65e0\u9700\u91cd\u590d\u6dfb\u52a0<\/strong>&nbsp;<code>nginx-rtmp-module<\/code>&nbsp;\u6a21\u5757\u3002<\/p>\n\n\n\n<p>\u4e0a\u8ff0\u547d\u4ee4\u4e2d\u8fd8\u5305\u542b\u4e86&nbsp;<code>--with-http_ssl_module<\/code>&nbsp;\u53c2\u6570\uff0c\u662f\u6839\u636e&nbsp;<code>nginx-rtmp-module<\/code>&nbsp;\u7684<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/arut\/nginx-rtmp-module#Build\" target=\"_blank\">\u7f16\u8bd1\u5b89\u88c5\u8bf4\u660e<\/a>\u8fdb\u884c\u7684\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u4e09\u3001\u7f16\u8f91 nginx.conf<\/h4>\n\n\n\n<p>\u4f7f\u7528 vi \u6216\u5176\u4ed6\u7f16\u8f91\u5de5\u5177\u7f16\u8f91&nbsp;<code>\/usr\/local\/nginx\/conf\/nginx.conf<\/code>&nbsp;\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">worker_processes  1;\n\nevents {\n    worker_connections  1024;\n}\n\nrtmp {\n    server {\n        listen 9999;  # \u63a5\u53d7\u63a8\u6d41\u7684\u7aef\u53e3\u53f7\n        chunk_size 8192; # \u5355\u4e00\u63a8\u6d41\u6570\u636e\u5305\u7684\u6700\u5927\u5bb9\u91cf\uff1f\n\n        application myapp { # myapp \u6a21\u5757\uff0c\u53ef\u4ee5\u81ea\u884c\u66f4\u6362\u540d\u5b57\n            live on; # \u6253\u5f00\u76f4\u64ad\n            # \u975e\u5e38\u91cd\u8981\uff0c \u8bbe\u5b9a\u8ba9ngnix\u65ad\u5f00\u963b\u585e\u4e2d\u7684\u8fde\u63a5\uff0c \u624d\u80fd\u89e6\u53d1exec_record_done\n            # \u4ee5\u53ca\u5ba2\u6237\u7aef\u7684LFLiveKit reconnectCount\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\u624d\u4f1a\u597d\u7528\n            drop_idle_publisher 5s;\n            meta off; # \u4e3a\u4e86\u517c\u5bb9\u7f51\u9875\u524d\u7aef\u7684 flv.js\uff0c\u8bbe\u7f6e\u4e3a off \u53ef\u4ee5\u907f\u514d\u62a5\u9519\n            gop_cache on; # \u652f\u6301GOP\u7f13\u5b58\uff0c\u4ee5\u51cf\u5c11\u9996\u5c4f\u65f6\u95f4\n            allow play all; # \u5141\u8bb8\u6765\u81ea\u4efb\u4f55 ip \u7684\u4eba\u62c9\u6d41\n        }\n    }\n}\n\nhttp {\n    include       mime.types;\n    default_type  application\/octet-stream;\n\n    sendfile        on;\n    keepalive_timeout  65;\n\n    server {\n        listen       8080;  # http \u670d\u52a1\u7684\u7aef\u53e3\n        server_name  localhost;\n\n        location \/live { # \u62c9\u6d41\u65f6\u7684 uri \uff0c\u53ef\u4ee5\u81ea\u884c\u4fee\u6539\n            flv_live on; # \u6253\u5f00 http-flv \u670d\u52a1\n            chunked_transfer_encoding on;\n            add_header 'Access-Control-Allow-Origin' '*'; # \u5141\u8bb8\u8de8\u57df\n            add_header 'Access-Control-Allow-Credentials' 'true';\n        }\n\n    }\n\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u56db\u3001\u542f\u52a8 Nginx<\/h4>\n\n\n\n<p>\u542f\u52a8\u4f4d\u4e8e&nbsp;<code>\/usr\/local\/nginx\/sbin<\/code>&nbsp;\u7684 nginx<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">.\/nginx\n<\/pre>\n\n\n\n<p>\u5f53\u4f7f\u7528\u5982\u4e0a\u914d\u7f6e\u5f00\u542f Nginx \u65f6\uff0c\u63a8\u6d41\u548c\u62c9\u6d41\u7684\u5730\u5740\u5206\u522b\u662f\u8fd9\u6837\uff1a<\/p>\n\n\n\n<ul><li>\u63a8\u6d41\u5730\u5740:&nbsp;<code>rtmp:\/\/localhost:9999\/myapp\/mystream<\/code><\/li><li>\u62c9\u6d41\u5730\u5740\uff1a<code>http:\/\/localhost:8080\/live?port=9999&amp;app=myapp&amp;stream=mystream<\/code><\/li><\/ul>\n\n\n\n<p>\u5176\u4e2d\u7684&nbsp;<code>myapp<\/code>&nbsp;\u6307\u7684\u662f\u914d\u7f6e\u6587\u4ef6(nginx.conf)\u4e2d&nbsp;<code>rtmp<\/code>&nbsp;\u5757\u6307\u5b9a\u7684&nbsp;<code>application<\/code>\uff0c\u4e00\u4e2a&nbsp;<code>rtmp server<\/code>\u53ef\u4ee5\u62e5\u6709\u591a\u4e2a&nbsp;<code>application<\/code>\uff0c\u53ea\u8981\u540d\u5b57\u5bf9\u5e94\u7684\u4e0a\uff0c\u53eb\u5565\u90fd\u53ef\u4ee5\u3002<\/p>\n\n\n\n<p>\u793a\u4f8b\u5730\u5740\u4e2d\u7684&nbsp;<code>mystream<\/code>&nbsp;\u53ef\u4ee5\u7531\u7528\u6237\u81ea\u5df1\u6307\u5b9a\uff0c\u53ea\u8981\u62c9\u6d41\u5730\u5740\u7684\u53c2\u6570<code>stream<\/code>\u5bf9\u5e94\u7684\u4e0a\u5c31\u884c\u4e86\uff0c\u6709\u70b9\u7c7b\u4f3c\u4e8e\u623f\u95f4\u7684\u6982\u5ff5\uff0c\u63a8\u6d41\u8981\u63a8\u5230\u54ea\u4e2a<code>application<\/code>\u5e95\u4e0b\u7684\u54ea\u4e2a\u623f\u95f4\u7684\u611f\u89c9\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\u4e94\u3001\u4f7f\u7528-obs-\u63a8\u6d41\">\u4e94\u3001\u4f7f\u7528 OBS \u63a8\u6d41<\/h4>\n\n\n\n<p>\u6211\u8fd9\u91cc\u4f7f\u7528\u7684\u662f&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/obsproject.com\/download\" target=\"_blank\">OBS<\/a>&nbsp;\u8f6f\u4ef6\u8fdb\u884c\u63a8\u6d41\uff0c\u6253\u5f00&nbsp;<code>OBS \u8bbe\u7f6e\u9762\u677f &gt; \u6d41<\/code><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/01\/image-35-1024x799.png\" alt=\"\" class=\"wp-image-1464\" width=\"-39\" height=\"-30\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-1024x799.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-300x234.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-768x599.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-830x647.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-230x179.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-350x273.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35-480x374.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-35.png 1436w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<ol><li>\u5c06\u670d\u52a1\u8bbe\u7f6e\u4e3a:&nbsp;<code>\u81ea\u5b9a\u4e49<\/code><\/li><li>\u670d\u52a1\u5668\u8bbe\u7f6e\u4e3a\u4e0d\u5305\u542b\u623f\u95f4\u540d\u7684\u63a8\u6d41\u5730\u5740\u793a\u4f8b:&nbsp;<code>rtmp:\/\/localhost:9999\/myapp\/<\/code><\/li><li>\u6d41\u79d8\u94a5\u8bbe\u7f6e\u4e3a\u623f\u95f4\u540d:&nbsp;<code>mystream<\/code><\/li><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u516d\u3001\u4f7f\u7528 flv.js \u62c9\u6d41<\/h4>\n\n\n\n<p>\u901a\u8fc7&nbsp;<a href=\"https:\/\/github.com\/bilibili\/flv.js\" target=\"_blank\" rel=\"noreferrer noopener\">flv.js<\/a>&nbsp;\u53ef\u4ee5\u76f4\u63a5\u5728\u7f51\u9875\u4e0a\u64ad\u653e\u6211\u4eec\u521a\u521a\u8fdb\u884c\u63a8\u6d41\u7684\u97f3\u89c6\u9891\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u63d0\u4f9b\u6700\u57fa\u7840\u7684\u4ee3\u7801\u7247\u6bb5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;script src=\"flv.min.js\">&lt;\/script>\n&lt;video id=\"videoElement\">&lt;\/video>\n&lt;script>\n    if (flvjs.isSupported()) {\n        var videoElement = document.getElementById('videoElement');\n        var flvPlayer = flvjs.createPlayer({\n            type: 'flv',\n            isLive:true, \/\/ \u5982\u679c\u662f\u76f4\u64ad\u6d41\u9700\u8981\u8bbe\u7f6e\u8fd9\u4e2a\u503c\u4e3a true\n            url: 'http:\/\/localhost:8080\/live?port=9999&amp;app=myapp&amp;stream=mystream'\n        \/\/ \u2191 \u62c9\u6d41\u793a\u4f8b\u5730\u5740\uff0cstream\u53c2\u6570\u4e00\u5b9a\u8981\u548c\u63a8\u6d41\u65f6\u6240\u8bbe\u7f6e\u7684\u6d41\u5bc6\u94a5\u4e00\u81f4\n        });\n        flvPlayer.attachMediaElement(videoElement);\n        flvPlayer.load();\n        flvPlayer.play();\n    }\n&lt;\/script><\/pre>\n\n\n\n<p>\u8fd0\u884c\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"610\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/01\/image-36-1024x610.png\" alt=\"\" class=\"wp-image-1467\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-1024x610.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-300x179.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-768x458.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-830x494.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-230x137.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-350x209.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36-480x286.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-36.png 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">\u9644\uff1aDocker \u914d\u7f6e nginx-http-flv\u670d\u52a1\u5668<\/h4>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\uff0c\u901a\u8fc7docker\u76f4\u63a5\u4f7f\u7528nginx-http-flv-module\u955c\u50cf\uff0c\u8fd9\u6837\u80fd\u7701\u53bb\u5f88\u591a\u914d\u7f6e\u7684\u65f6\u95f4\u3002nginx-http-flv-module \u662f\u57fa\u4e8e nginx-rtmp-module \u5f00\u53d1\u7684\uff0c\u5b8c\u5168\u517c\u5bb9 nginx-rtmp-module \u7684\u6240\u6709\u529f\u80fd\u3002<\/p>\n\n\n\n<p>docker\u955c\u50cf\u5730\u5740\uff1ahttps:\/\/hub.docker.com\/r\/mycujoo\/nginx-http-flv-module<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/01\/image-38-1024x482.png\" alt=\"\" class=\"wp-image-1471\" width=\"-16\" height=\"-7\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-1024x482.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-300x141.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-768x362.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-1536x723.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-2048x964.png 2048w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-830x391.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-230x108.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-350x165.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/01\/image-38-480x226.png 480w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u7528\u4e0b\u9762\u547d\u4ee4\u6765\u4e0b\u8f7d\u955c\u50cf\u542f\u52a8\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u4e0b\u8f7d\u955c\u50cf\ndocker pull mycujoo\/nginx-http-flv-module\n\/\/ \u67e5\u770b\u955c\u50cf\ndocker images\n\/\/ \u8fd0\u884c\u5bb9\u5668\ndocker run -d -p 1965:1965 -p 8181 --name http-flv mycujoo\/nginx-http-flv-module:latest\n\/\/ \u7528\u8fd9\u4e2a\u547d\u4ee4\u53ef\u4ee5\u8fdb\u5165\u5230docker\u5185\u90e8\ndocker exec -it http-flv sh<\/pre>\n\n\n\n<p>\u4f46\u662f\u6211\u4eec\u53ef\u80fd\u9700\u8981\u81ea\u5df1\u914d\u7f6engnix\uff0c\u9700\u8981\u4fee\u6539ngnix config\u6587\u4ef6\u3002\u8fd9\u6837\u7684\u8bdd\uff0c\u6211\u4eec\u9700\u8981\u77e5\u9053docker \u955c\u50cf\u4e2d\uff0cngnix.config\u4e2d\u7684\u4f4d\u7f6e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u7684\u547d\u4ee4\u627e\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u9996\u5148\u7528\u8fd9\u4e2a\u547d\u4ee4\u8fdb\u5165docker\u5bb9\u5668\ndocker exec -it http-flv sh\n\n\/\/ \u7528\u8fd9\u4e2a\u547d\u4ee4\u627e\u5230nginx.conf\u6587\u4ef6\u5728\u955c\u50cf\u4e2d\u7684\u4f4d\u7f6e\uff0c\u53ef\u4ee5\u627e\u5230\u5728 \/opt\/nginx\/nginx.conf\nfind \/ -name nginx.conf<\/pre>\n\n\n\n<p>Dockerfile\uff08\u7528\u6211\u4eec\u81ea\u5df1\u7684nginx.conf\u6587\u4ef6\u8986\u76d6\u6389 docker\u955c\u50cf\u4e2d\/opt\/nginx\/nginx.conf\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">FROM mycujoo\/nginx-http-flv-module\nCOPY nginx.conf \/opt\/nginx\/nginx.conf<\/pre>\n\n\n\n<p>\u81ea\u5df1\u7684ngnix.comfig<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">daemon off;\nerror_log \/var\/log\/nginx\/error.log warn;\nevents {\nworker_connections 1024;\n}\nrtmp {\nout_queue   4096;\nout_cork    8;\nmax_streams 64;\n\n\nserver {\n    listen 1935;\n\n    application live {\n        live on;\n        record all;\n        record_path \/tmp;\n        record_max_size 10485760K;\n        record_unique off;\n        record_append on;\n        gop_cache on; #open GOP cache for reducing the wating time for the first picture of video\n    }\n    # \u975e\u5e38\u91cd\u8981\uff0c \u8bbe\u5b9a\u8ba9ngnix\u65ad\u5f00\u963b\u585e\u4e2d\u7684\u8fde\u63a5\uff0c \u624d\u80fd\u89e6\u53d1exec_record_done\n    # \u4ee5\u53ca\u5ba2\u6237\u7aef\u7684LFLiveKit reconnectCount\u81ea\u52a8\u91cd\u65b0\u8fde\u63a5\u624d\u4f1a\u597d\u7528\n    drop_idle_publisher 30s;\n    ping 20s;\n    ping_timeout 10s;\n    meta on;\n    chunk_size 4096;\n    wait_video on;\n    wait_key on;\n\n    application hls {\n        live on;\n        record all;\n        record_append on;\n        record_max_size 10485760K;\n        record_path \/opt\/data\/hls;\n        hls on;\n        hls_fragment_naming system;\n        hls_fragment 5s;\n        hls_path \/opt\/data\/hls;\n        hls_nested on;\n    }\n}<\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>http {<br>include mime.types;<br>default_type application\/octet-stream;<br>keepalive_timeout 65;<br>log_format main &#8216;$remote_addr &#8211; $remote_user [$time_local] &#8220;$request&#8221; &#8216;<br>&#8216;$status $body_bytes_sent &#8220;$http_referer&#8221; &#8216;<br>&#8216;&#8221;$http_user_agent&#8221; &#8220;$http_x_forwarded_for&#8221;&#8216;;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">access_log \/var\/log\/nginx\/access.log;\n\nserver {\n    listen 8080;\n\n    location \/live {\n        flv_live on; #open flv live streaming (subscribe)\n        chunked_transfer_encoding  off; #open 'Transfer-Encoding: chunked' response\n\n        add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header\n        add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header\n    }\n\n     location ~ ^\/play\/(.*)\\.flv {\n        proxy_redirect off;\n        proxy_pass http:\/\/127.0.0.1\/live?app=live&amp;stream=$1;\n    }\n\n    location \/hls {\n        types {\n            application\/vnd.apple.mpedaemon off;\n\nerror_log \/var\/log\/nginx\/error.log warn;\n\nevents {\n    worker_connections 1024;\n}\n\nrtmp {\n\n    out_queue   4096;\n    out_cork    8;\n    max_streams 64;\n\n\n    server {\n        listen 1935;\n\n        application rtmplive {\n            live on;\n            record all;\n            record_path \/tmp;\n            record_max_size 10485760K;\n            record_unique off;\n            record_append on;\n            gop_cache on; #open GOP cache for reducing the wating time for the first picture of video\n            allow play all;\n            meta off;\n        }\n\n        application hls {\n            live on;\n            hls on;\n            record all;\n            record_append on;\n            record_max_size 10485760K;\n            record_path \/opt\/data\/hls;\n            hls_fragment_naming system;\n            hls_fragment 5s;\n            hls_path \/opt\/data\/hls;\n        }\n    }\n}\n\nhttp {\n    include mime.types;\n    default_type application\/octet-stream;\n    sendfile on;\n    keepalive_timeout 65;\n\n    access_log \/var\/log\/nginx\/access.log;\n\n    server {\n        listen 8080;\n\n        location \/live {\n            flv_live on; #open flv live streaming (subscribe)\n            chunked_transfer_encoding  off; #open 'Transfer-Encoding: chunked' response\n\n            add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header\n            add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header\n        }\n\n        location \/hls {\n            types {\n                application\/vnd.apple.mpegurl m3u8;\n                video\/mp2t ts;\n            }\n            root \/opt\/data;\n            add_header Cache-Control no-cache;\n            add_header Access-Control-Allow-Origin *;\n        }\n    }\n}gurl m3u8;\n            video\/mp2t ts;\n        }\n        root \/opt\/data;\n        add_header Cache-Control no-cache;\n        add_header Access-Control-Allow-Origin *;\n    }\n\n    location \/stat {\n       rtmp_stat all;\n       rtmp_stat_format json;\n    }\n\n    location \/static {\n        alias \/www\/static;\n    }\n\n    location = \/crossdomain.xml {\n        root \/www\/static;\n        default_type text\/xml;\n        expires 24h;\n    }\n}<\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>\u7528\u4e0b\u9762\u547d\u4ee4build\u955c\u50cf\uff0c\u5e76\u542f\u52a8<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker build -t nginx-rtmp .\ndocker run -d -p 1935:1935 -p 8080:8080 -v \/tmp\/video:\/tmp -v \/tmp\/hls:\/opt\/data\/hls --privileged=true --name nginx-rtmp nginx-rtmp\n<\/pre>\n\n\n\n<p>HLS \u63a8\u6d41url\uff1artmp:\/\/123.57.164.21:1935\/hls\/cs<\/p>\n\n\n\n<p>HLS \u62c9\u6d41url\uff1ahttp:\/\/123.57.164.21:8080\/hls\/cs.m3u8<\/p>\n\n\n\n<p>rtmp\u63a8\u6d41url\uff1artmp:\/\/123.57.164.21:1935\/rtmplive\/cs<\/p>\n\n\n\n<p>flv\u62c9\u6d41url\uff1ahttp:\/\/123.57.164.21:8080\/live?port=1935&amp;app=rtmplive&amp;stream=cs<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u7f6e\u77e5\u8bc6 \u5728\u642d\u5efa\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u76f4\u64ad\u8fd9\u4e2a\u6982\u5ff5\u672c\u8eab\u6709\u4e00\u4e2a\u5927\u6982\u7684\u7406\u89e3\u3002 \u6211\u4eec\u7ecf\u5e38\u542c\u5230\u4e24\u4e2a\u8bcd\uff1a\u63a8\u6d41(push\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1458"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1458"}],"version-history":[{"count":16,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1458\/revisions"}],"predecessor-version":[{"id":1958,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/1458\/revisions\/1958"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}