{"id":20,"date":"2021-02-03T15:13:00","date_gmt":"2021-02-03T07:13:00","guid":{"rendered":"https:\/\/sy-blog.top:100\/?p=18"},"modified":"2025-05-26T10:20:19","modified_gmt":"2025-05-26T02:20:19","slug":"%e4%bd%bf%e7%94%a8%e5%ae%9d%e5%a1%94%e9%9d%a2%e6%9d%bf%e6%90%ad%e5%bb%ba%e7%9b%b4%e6%92%ad%e7%b3%bb%e7%bb%9f-nginxrtmphls","status":"publish","type":"post","link":"https:\/\/sy-blog.moe\/en\/20.html","title":{"rendered":"Building a Live Streaming System Using BT Panel \u2014\u2014 Nginx + RTMP + HLS"},"content":{"rendered":"<p>Environment: Ubuntu 20.04.1, Baota Linux Panel, nginx 1.19.6<\/p>\n<h1>Build steps<\/h1>\n<p>Please install the pagoda panel yourself<\/p>\n<h2>1. Compile nginx<\/h2>\n<p>To use rtmp, you need to use nginx&#039;s rtmp module, so you need to recompile nginx<\/p>\n<p>1. Login panel-software store-nginx-compile and install-add custom module<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-29\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/010656iuurraayhay3uxry.png\" alt=\"\" width=\"398\" height=\"321\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/010656iuurraayhay3uxry.png 398w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/010656iuurraayhay3uxry-300x242.png 300w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>2. Enter nginx_rtmp_module for module name and description, and fill in --add-module=\/www\/server\/nginx\/src\/nginx-rtmp-module for parameters.<\/p>\n<p>Pre-script input:<\/p>\n<pre class=\"hl\"><code class=\"\">git clone https:\/\/github.com\/arut\/nginx-rtmp-module.git<\/code><\/pre>\n<p>3. Submit, select the module, submit, and wait for the compilation to complete<\/p>\n<p>4. Enter nginx -V in the command line to check whether the installation is successful<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-28\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-143917_LI.jpg\" alt=\"\" width=\"1172\" height=\"190\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-143917_LI.jpg 1172w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-143917_LI-300x49.jpg 300w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-143917_LI-1024x166.jpg 1024w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-143917_LI-768x125.jpg 768w\" sizes=\"auto, (max-width: 1172px) 100vw, 1172px\" \/><\/p>\n<h2>2. Configure rtmp<\/h2>\n<p>Software Store-nginx-Settings-Configuration Modification<br \/>\nAdd rtmp configuration in it<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-27\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-144925-750x673-1.png\" alt=\"\" width=\"750\" height=\"673\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-144925-750x673-1.png 750w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-144925-750x673-1-300x269.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<pre class=\"hl\"><code class=\"\">rtmp { server { listen 1935; #rtmp listening port, default 1935 chunk_size 4096; # packet size application live { live on; hls on; hls_path \/tmp\/hls; # hls file (m3u8, ts) save directory hls_fragment 3s; } } }\n<\/code><\/pre>\n<p>save<\/p>\n<h2>3. Configure hls<\/h2>\n<p>Baota Panel-Website-Add Site<\/p>\n<p>Please fill in the information here according to the actual situation<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-30\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145305-750x577-1.png\" alt=\"\" width=\"750\" height=\"577\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145305-750x577-1.png 750w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145305-750x577-1-300x231.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<p>After the new creation is completed, enter the site settings-configuration file<\/p>\n<p>Add hls configuration<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-31\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145546-750x387-1.png\" alt=\"\" width=\"750\" height=\"387\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145546-750x387-1.png 750w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-145546-750x387-1-300x155.png 300w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/p>\n<pre class=\"hl\"><code class=\"\">location \/live { types { application\/vnd.apple.mpegurl m3u8; video\/mp2t ts; } alias \/tmp\/hls; # is consistent with the hls directory just set add_header Cache-Control no-cache; }\n<\/code><\/pre>\n<p>save<\/p>\n<h1>test<\/h1>\n<h2>rtmp test<\/h2>\n<p>Start OBS, set the streaming target, fill in the server address, and write a random streaming key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-25 size-full\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-150348.png\" alt=\"\" width=\"967\" height=\"421\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-150348.png 967w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-150348-300x131.png 300w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-150348-768x334.png 768w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>Start streaming<\/p>\n<p>Open vlc-Network Stream, enter the set rtmp address, click play to see the picture<\/p>\n<h2>HLS test<\/h2>\n<p>vlc-network streaming, enter [kbd][http\/https]:\/\/[server address]\/live\/[streaming key].m3u8[\/kbd], click play to see the screen<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-24 size-full\" src=\"http:\/\/23.97.70.13\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-151130.png\" alt=\"\" width=\"530\" height=\"386\" srcset=\"https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-151130.png 530w, https:\/\/sy-blog.moe\/wp-content\/uploads\/2021\/02\/\u5c4f\u5e55\u622a\u56fe-2021-02-03-151130-300x218.png 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/p>\n<p>&nbsp;<\/p>\n<blockquote><p>Reference articles:<\/p>\n<p><a href=\"https:\/\/www.bt.cn\/bbs\/thread-51618-1-1.html\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/www.bt.cn\/bbs\/thread-51618-1-1.html<\/a><\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"Start the Baota panel, easily compile and install Nginx that supports Rtmp and Hls modules, and start an efficient live broadcast system. Detailed steps will help you go from command line to smooth streaming, witness the charm of technology step by step, and explore the new world of live broadcasting immediately!","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[3],"tags":[6,8,10,13],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx","tag-8","tag-10","tag-13"],"_links":{"self":[{"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":1,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"predecessor-version":[{"id":751,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/posts\/20\/revisions\/751"}],"wp:attachment":[{"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sy-blog.moe\/en\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}