{"id":12929,"date":"2025-04-18T20:03:02","date_gmt":"2025-04-18T12:03:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12929.html"},"modified":"2025-04-18T20:03:02","modified_gmt":"2025-04-18T12:03:02","slug":"%e6%90%ad%e5%bb%ba%e7%ae%80%e6%98%93%e7%9a%84rtsp%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12929.html","title":{"rendered":"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668"},"content":{"rendered":"<p id=\"u93f722b8\">\u672c\u6587\u4ecb\u7ecd\u7684\u662fmediamtx\u670d\u52a1\u5668&#xff08;\u539frtsp-simple-server&#xff09;\u7684\u914d\u7f6e&#xff0c;\u9644\u5e26\u4e00\u4e2a\u5173\u4e8enginx\u642d\u5efa\u53ef\u7528rtsp\u8f6c\u63a5\u4e3ahttp\u7aef\u53ef\u76f4\u63a5\u8bbf\u95ee\u7684\u65b9\u6848<\/p>\n<h3 id=\"frpKs\">mediamtx\u4f18\u70b9<\/h3>\n<p id=\"ub8faee91\">1.\u4e0d\u7ba1\u662f\u5728windows\u8fd8\u662flinux&#xff0c;\u5b89\u88c5\u548c\u4f7f\u7528\u90fd\u6781\u5176\u7b80\u5355&#xff1b;<\/p>\n<p id=\"u1f0b3b85\">2.\u4f5c\u8005\u5199\u7684\u6587\u6863\u6bd4\u8f83\u8be6\u7ec6&#xff0c;\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u95ee\u9898\u5f88\u5c11&#xff0c;\u4e0d\u9700\u8981\u53bb\u53c2\u8003\u5176\u4ed6\u6587\u6863&#xff1b;<\/p>\n<p id=\"uca7ad7a9\">3.\u5728github\u4e0a\u8fdb\u884c\u63d0\u95ee\u4ee5\u53cabug\u63d0\u4ea4\u4f5c\u8005\u90fd\u80fd\u56de\u590d\u5e76\u53ca\u65f6\u4fee\u590dbug&#xff1b;<\/p>\n<p id=\"uf8eaca6d\">4.\u652f\u6301rtsp\u3001rtmp\u3001hsl&#xff1b;\u5e76\u4e14\u5ef6\u8fdf\u5904\u7406\u7684\u6bd4\u8f83\u597d&#xff1b;<\/p>\n<p id=\"u843e81a5\">5..\u96c6\u6210webrtc\u53ef\u76f4\u63a5\u64ad\u653e\u89c6\u9891&#xff1b;<\/p>\n<p id=\"u4cdf7a08\">6.\u53ef\u8fdb\u884c\u89c6\u9891\u8bbf\u95ee\u52a0\u5bc6\u5904\u7406&#xff1b;<\/p>\n<h3 id=\"xkjv8\">mediamtx\u5b89\u88c5<\/h3>\n<p id=\"u287c514e\">\u6ce8&#xff1a;\u672c\u4eba\u7684docker\u6ca1\u627e\u5230\u7a33\u5b9a\u7684\u955c\u50cf\u4ed3\u5e93&#xff0c;\u6240\u4ee5\u53ea\u8bd5\u9a8c\u8fc7\u901a\u8fc7\u4e8c\u8fdb\u5236\u6587\u4ef6\u7f16\u7801\u5b89\u88c5\u3002docker\u65b9\u6848\u6ca1\u8bd5\u8fc7&#xff0c;\u4e0d\u8fc7\u5e94\u8be5\u4f1a\u66f4\u8f7b\u677e\u70b9<\/p>\n<h4 id=\"DTX8f\">\u4e8c\u8fdb\u5236\u5b89\u88c5<\/h4>\n<p id=\"ud31116da\">1.\u5728\u5b98\u7f51\u4e0b\u8f7d\u9879\u76ee&#xff0c;\u9009\u62e9linux\u7684amd64\u7248&#xff0c;\u5982\u56fe<\/p>\n<p id=\"u9d5b08ee\">\u5b98\u7f51\u8fde\u63a5&#xff1a;https:\/\/github.com\/bluenviron\/mediamtx\/releases<\/p>\n<p id=\"u909bb5e7\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"582\" id=\"ucec24a00\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f750c5c7.png\" width=\"1308\" \/><\/p>\n<p id=\"uadbff567\">2.\u89e3\u538b\u5e76\u653e\u5230\u4f60\u5e0c\u671b\u7684\u4f4d\u7f6e<\/p>\n<p id=\"uee883913\">\u53ef\u901a\u8fc7shell\u8f6f\u4ef6&#xff0c;\u5c06\u5176\u76f4\u63a5\u653e\u5230\u4f60\u5e0c\u671b\u7684\u4f4d\u7f6e&#xff0c;\u5e76\u901a\u8fc7tar\u89e3\u538b<\/p>\n<p id=\"u8f0440a7\">tar -xzvf \u4f60\u7684\u538b\u7f29\u5305 <\/p>\n<p id=\"ua092d574\">3.\u542f\u52a8mediamtx<\/p>\n<p id=\"ud14f228e\">\u5728\u89e3\u538b\u5b8c\u540e\u4f60\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u51e0\u4e2a\u6587\u4ef6<\/p>\n<p id=\"ubd50a340\">\n<p id=\"uaa098d5e\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"128\" id=\"u54ffd7ac\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f754d47d.png\" width=\"969\" \/><\/p>\n<p id=\"u2512435f\">\u8fd9\u91cc\u9762mediamtx\u6587\u4ef6\u662f\u542f\u52a8\u5668<\/p>\n<p id=\"ued98c149\">mediamtx.yml\u662fmediamtx\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u4e00\u822c\u4e0d\u9700\u8981\u4e8c\u6b21\u914d\u7f6e<\/p>\n<p id=\"u25236f63\">\u5982\u679c\u60f3\u542f\u52a8mediamtx&#xff0c;\u53ef\u7528\u8f93\u5165\u5982\u4e0b\u4ee3\u7801\u542f\u52a8&#xff08;\u5728\u8be5\u6587\u4ef6\u5939\u5185&#xff09;<\/p>\n<p id=\"ud7dc2bae\">.\/mediamtx<\/p>\n<h4 id=\"MNTFM\">docker\u5b89\u88c5<\/h4>\n<p id=\"u289f59f1\">\u8c8c\u4f3c\u53ea\u9700\u8981\u4e0b\u9762\u7684\u4ee3\u7801\u5c31\u884c<\/p>\n<p>docker run &#8211;rm -it &#8211;network&#061;host bluenviron\/mediamtx:latest <\/p>\n<p id=\"u4ae9d20e\">\u672a\u5b9e\u9a8c\u8fc7&#xff0c;\u4e0d\u77e5\u80fd\u4e0d\u80fd\u7528<\/p>\n<h4 id=\"wj3cC\">mediamtx \u7aef\u53e3<\/h4>\n<p id=\"u9b4acd1d\">rtmp server\u7aef\u53e3&#xff1a;1935<\/p>\n<p id=\"ue22d1138\">rtsp server\u7aef\u53e3&#xff1a;8554<\/p>\n<p id=\"u574d0430\">hls server\u7aef\u53e3&#xff1a;8888<\/p>\n<p id=\"u10bf1d29\">webrtc server\u7aef\u53e3&#xff1a;8889<\/p>\n<p id=\"uc2207d57\">[RTSP] listener opened on :8554 (TCP), :8000 (UDP\/RTP), :8001 (UDP\/RTCP)<\/p>\n<p id=\"ud9f93a7a\">[HLS] listener opened on :8888<\/p>\n<p id=\"u1dfb4737\">[WebRTC] listener opened on :8889 (HTTP), :8189 (ICE\/UDP)<\/p>\n<p id=\"uafafba23\">[SRT] listener opened on :8890 (UDP)<\/p>\n<h4 id=\"y2u8V\">\u5b9e\u73b0\u5f00\u673a\u81ea\u542f\u52a8<\/h4>\n<p id=\"u3a17a190\">1.\u521b\u5efa\u670d\u52a1\u6587\u4ef6<\/p>\n<p id=\"ue57a679a\">\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a mediamtx.service \u7684\u6587\u4ef6&#xff0c;\u901a\u5e38\u4f4d\u4e8e \/etc\/systemd\/system\/ \u76ee\u5f55\u4e0b\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u6765\u521b\u5efa\u8fd9\u4e2a\u6587\u4ef6&#xff0c;\u4f8b\u5982\u4f7f\u7528 vi \u6216 nano&#xff1a;<\/p>\n<p>sudo vi \/etc\/systemd\/system\/mediamtx.service <\/p>\n<p id=\"udaa5f2aa\">2.\u7f16\u8f91\u670d\u52a1\u6587\u4ef6&#xff1a; \u5728 mediamtx.service \u6587\u4ef6\u4e2d&#xff0c;\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff0c;\u786e\u4fdd\u66ff\u6362 &lt;path-to-mediamtx&gt; \u4e3a\u4f60\u7684 MediaMTX \u53ef\u6267\u884c\u6587\u4ef6\u7684\u5b9e\u9645\u8def\u5f84&#xff1a;<\/p>\n<p>[Unit]<br \/>\nDescription&#061;MediaMTX Service<br \/>\nAfter&#061;network.target<\/p>\n<p>[Service]<br \/>\nType&#061;simple<br \/>\nExecStart&#061;&lt;path-to-mediamtx&gt;\/mediamtx<br \/>\nRestart&#061;on-failure<\/p>\n<p>[Install]<br \/>\nWantedBy&#061;multi-user.target <\/p>\n<p id=\"u257deb50\">\u8fd9\u91cc\u7684 ExecStart \u884c\u6307\u5b9a\u4e86\u542f\u52a8 MediaMTX \u7684\u547d\u4ee4\u3002\u5982\u679c\u4f60\u7684 MediaMTX \u914d\u7f6e\u6587\u4ef6\u4e0d\u662f\u4f4d\u4e8e\u9ed8\u8ba4\u4f4d\u7f6e&#xff0c;\u4f60\u8fd8\u9700\u8981\u5728\u547d\u4ee4\u4e2d\u4f7f\u7528 -c \u53c2\u6570\u6307\u5b9a\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n<p id=\"u3e11e666\">3.\u91cd\u65b0\u52a0\u8f7d systemd \u914d\u7f6e&#xff1a; \u4fdd\u5b58\u6587\u4ef6\u5e76\u9000\u51fa\u7f16\u8f91\u5668\u540e&#xff0c;\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u91cd\u65b0\u52a0\u8f7d systemd \u914d\u7f6e&#xff0c;\u4f7f\u65b0\u670d\u52a1\u6587\u4ef6\u751f\u6548&#xff1a;<\/p>\n<p>sudo systemctl daemon-reload <\/p>\n<p id=\"ua75f25d9\">4.\u542f\u7528\u670d\u52a1&#xff1a; \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u7528\u670d\u52a1&#xff0c;\u8fd9\u6837\u5b83\u5c31\u4f1a\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u81ea\u52a8\u542f\u52a8<\/p>\n<p>sudo systemctl enable mediamtx.service <\/p>\n<p id=\"u573fe37c\">\u5982\u679c\u4f60\u60f3\u7acb\u5373\u542f\u52a8\u670d\u52a1&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<p>sudo systemctl start mediamtx.service <\/p>\n<p id=\"u0b531d40\">5.\u68c0\u67e5\u670d\u52a1\u72b6\u6001&#xff1a; \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5\u670d\u52a1\u7684\u72b6\u6001&#xff0c;\u786e\u4fdd\u5b83\u6b63\u5728\u8fd0\u884c&#xff1a;<\/p>\n<p>sudo systemctl status mediamtx.service <\/p>\n<h4 id=\"jze38\">\u7b80\u5355\u4f7f\u7528<\/h4>\n<p id=\"uc71ebae5\">\u901a\u8fc7ffmpeg\u8fdb\u884c\u63a8\u62c9\u6d41&#xff0c;\u9ed8\u8ba4\u9700\u8981\u5b89\u88c5\u597dffmpeg<\/p>\n<p id=\"u7eb4c18f\">\u63a8\u9001\u89c6\u9891\u7ed9rtsp\u670d\u52a1\u5668<\/p>\n<p>ffmpeg -re -stream_loop -1 -i \u8981\u4f20\u7684\u89c6\u9891 -c copy -f rtsp rtsp:\/\/127.0.0.1:8554\/video<\/p>\n<p id=\"uc5fa27ce\">\u5176\u4e2d&#xff1a;<\/p>\n<p id=\"u38d57467\">\u8981\u4f20\u7684\u89c6\u9891\u6539\u6210\u81ea\u5df1\u89c6\u9891\u7684\u540d\u79f0&#xff0c;\u8981\u6c42\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84\u3002<\/p>\n<p id=\"uee2cf161\">\u540e\u9762rtsp:\/\/\u4e2d\u4e3a\u81ea\u5df1\u865a\u62df\u673a\u7684ip\u5730\u5740&#xff0c;\u4f8b&#xff1a;192.168.134.186:8854<\/p>\n<p id=\"uc9bd1ee7\">\u540e\u9762\u7684\u76ee\u5f55\u4e3a\u4e0a\u4f20\u5230\u7684\u76ee\u5f55&#xff0c;\u4f8b\/video<\/p>\n<p id=\"u9dd8b8fe\">\u8bbf\u95ee\u65f6\u4e5f\u662f\u901a\u8fc7\u8be5\u76ee\u5f55\u8bbf\u95ee<\/p>\n<p id=\"u5239554d\">\n<p id=\"u778f84a6\">\u63a8\u9001\u6444\u50cf\u5934\u7ed9\u670d\u52a1\u5668<\/p>\n<p>ffmpeg -f v4l2 -i \/dev\/video0 -c:v libx264 -preset veryfast -maxrate 2000k -bufsize 4000k -pix_fmt yuv420p -g 50 -r 25 -f rtsp rtsp:\/\/your_rtsp_server_ip:port\/stream_name <\/p>\n<p id=\"u8469d158\">\u8fd9\u91cc\u662f\u547d\u4ee4\u884c\u53c2\u6570\u7684\u89e3\u91ca&#xff1a;<\/p>\n<ul>\n<li id=\"uf11f14d2\">-f v4l2&#xff1a;\u6307\u5b9a\u8f93\u5165\u683c\u5f0f\u4e3aV4L2&#xff0c;\u8fd9\u662fLinux\u4e2d\u5e38\u7528\u7684\u6444\u50cf\u5934\u63a5\u53e3\u3002<\/li>\n<li id=\"u7aba2fc2\">-i \/dev\/video0&#xff1a;\u6307\u5b9a\u6444\u50cf\u5934\u8bbe\u5907\u6587\u4ef6&#xff0c;\/dev\/video0\u662f\u7b2c\u4e00\u4e2a\u6444\u50cf\u5934\u8bbe\u5907\u7684\u6807\u51c6\u8def\u5f84&#xff0c;\u5982\u679c\u6709\u591a\u4e2a\u6444\u50cf\u5934&#xff0c;\u53ef\u4ee5\u662f\/dev\/video1\u7b49\u3002<\/li>\n<li id=\"u903106c2\">-c:v libx264&#xff1a;\u6307\u5b9a\u89c6\u9891\u7f16\u89e3\u7801\u5668\u4e3aH.264\u3002<\/li>\n<li id=\"ue9a62d78\">-preset veryfast&#xff1a;\u8bbe\u7f6e\u7f16\u7801\u5668\u7684\u9884\u8bbe&#xff0c;veryfast\u662f\u4e00\u4e2a\u5e73\u8861\u901f\u5ea6\u548c\u8d28\u91cf\u7684\u9884\u8bbe\u3002<\/li>\n<li id=\"u1fbd85da\">-maxrate 2000k&#xff1a;\u8bbe\u7f6e\u6700\u5927\u6bd4\u7279\u7387\u3002<\/li>\n<li id=\"u6fa39773\">-bufsize 4000k&#xff1a;\u8bbe\u7f6e\u7f13\u51b2\u533a\u5927\u5c0f\u3002<\/li>\n<li id=\"ucf49a208\">-pix_fmt yuv420p&#xff1a;\u8bbe\u7f6e\u50cf\u7d20\u683c\u5f0f\u4e3aYUV420P&#xff0c;\u8fd9\u662fRTSP\u6d41\u5e38\u7528\u7684\u683c\u5f0f\u3002<\/li>\n<li id=\"u8817a0c3\">-g 50&#xff1a;\u8bbe\u7f6e\u5173\u952e\u5e27\u95f4\u9694&#xff0c;\u8fd9\u91cc\u662f\u6bcf50\u5e27\u4e00\u4e2a\u5173\u952e\u5e27\u3002<\/li>\n<li id=\"u752b5328\">-r 25&#xff1a;\u8bbe\u7f6e\u5e27\u7387\u4e3a25fps\u3002<\/li>\n<li id=\"ua17be501\">-f rtsp&#xff1a;\u6307\u5b9a\u8f93\u51fa\u683c\u5f0f\u4e3aRTSP\u3002<\/li>\n<li id=\"u67829061\">rtsp:\/\/your_rtsp_server_ip:port\/stream_name&#xff1a;RTSP\u670d\u52a1\u5668\u7684\u5730\u5740&#xff0c;\u5305\u62ecIP\u5730\u5740\u3001\u7aef\u53e3\u53f7\u548c\u6d41\u540d\u79f0\u3002<\/li>\n<\/ul>\n<p id=\"uae9f0bc1\">\n<p id=\"u3f3f840b\">\u5982\u679c\u60f3\u770b\u770b\u6548\u679c&#xff0c;\u53ef\u7528\u4f7f\u7528\u5e26\u6709\u7f51\u7edc\u76f4\u64ad\u529f\u80fd\u7684\u64ad\u653e\u5668&#xff0c;\u5982VLC media player<\/p>\n<p id=\"u1fa5e19e\">\n<p id=\"ue3568e56\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"497\" id=\"uc0418e1e\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f75606a7.png\" width=\"592\" \/><\/p>\n<p id=\"u8afdc2c7\">\u8f93\u5165rtsp\u670d\u52a1\u5668\u7684\u5730\u5740\u53ca\u5bf9\u5e94\u8def\u5f84<\/p>\n<p id=\"ub18dd47b\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"520\" id=\"u76f162cb\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f75772f4.png\" width=\"669\" \/><\/p>\n<p id=\"u9c6f1d77\">\n<p id=\"ueb3133d4\">\n<p id=\"u8230af3e\">\u76f8\u5173\u914d\u7f6e\u6587\u4ef6\u7684\u914d\u7f6e\u65b9\u5f0f\u8fd8\u5728\u7814\u7a76<\/p>\n<h3 id=\"YedLV\">\u9644\u5e26nginx\u4e00\u5219<\/h3>\n<p id=\"ud2f5f84e\">\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"718\" id=\"uc3bb7f4e\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f758eea1.png\" width=\"1085\" \/><\/p>\n<p id=\"ubf688aac\">\u5176\u5b9e\u539f\u7406\u5c31\u662f: \u5c06\u76d1\u63a7\u901a\u8fc7FFMPEG,\u63a8\u9001\u7ed9Nginx,\u524d\u7aef\u901a\u8fc7Nginx\u5730\u5740\u62c9\u53d6\u89c6\u9891&#xff0c;\u5c31\u53ef\u4ee5\u64ad\u653e\u4e86\u3002<\/p>\n<p id=\"u821385e2\">\n<p id=\"ue51d3cc8\">\u5b89\u88c5nginx\u5230\u670d\u52a1\u5668&#xff0c;\u5e76\u4e0a\u4f20\u5230\u670d\u52a1\u5668&#xff0c;\u653e\u5230\u81ea\u5df1\u60f3\u653e\u5230\u7684\u4f4d\u7f6e<\/p>\n<p id=\"ufe1454b1\">\u4e0b\u8f7d\u5730\u5740nginx: download<\/p>\n<p id=\"uf8abcb20\">\u5982\u679c\u662f\u538b\u7f29\u5305&#xff0c;\u8bb0\u5f97\u5148\u89e3\u538b<\/p>\n<p id=\"u69c01523\">\u7ed9nginx\u5b89\u88c5nginx-http-flv-module\u6a21\u5757<\/p>\n<p id=\"u3904b416\">\u5efa\u8bae\u76f4\u63a5\u4e0b\u8f7d\u5230nginx\u76ee\u5f55\u4e0b<\/p>\n<p id=\"uef2c9afc\">\u4e0b\u8f7d\u5730\u5740&#xff1a; https:\/\/github.com\/winshining\/nginx-http-flv-module<\/p>\n<p id=\"u93bbc6fa\">\u9700\u8981\u5b89\u88c5\u7684\u4f9d\u8d56<\/p>\n<p>yum -y install unzip<br \/>\nyum -y install gcc-c&#043;&#043;<br \/>\nyum -y install pcre pcre-devel<br \/>\nyum -y install zlib zlib-devel<br \/>\nyum -y install openssl openssl-devel <\/p>\n<p id=\"uc52d146f\">\u5c06nginx-http-flv-module\u6a21\u677f\u6dfb\u52a0\u5230nginx\u4e2d&#xff0c;\u751f\u6210make\u6587\u4ef6 \u5e76\u5b89\u88c5nginx<\/p>\n<p>.\/configure &#8211;prefix&#061;\/usr\/local\/nginx  &#8211;add-module&#061;\/usr\/local\/nginx\/nginx-http-flv-module<br \/>\nmake &amp;&amp; make install<\/p>\n<p id=\"uf51be53b\">\u5b89\u88c5\u597d\u540e\u9700\u8981\u66f4\u6539nginx\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6765\u5b9e\u73b0\u76f8\u5173\u529f\u80fd<\/p>\n<p id=\"u50c4f296\">\u7f16\u8f91nginx\u6587\u4ef6&#xff1a; vim conf\/nginx.conf<\/p>\n<p id=\"u93008794\">\u4e0b\u9762\u63d0\u4f9b\u4e00\u4efd\u5b8c\u6574\u7684nginx\u6587\u4ef6<\/p>\n<p>worker_processes  10; #should be 1 for Windows, for it doesn&#039;t support Unix domain socket<br \/>\n#worker_processes  auto; #from versions 1.3.8 and 1.2.5<\/p>\n<p>#worker_cpu_affinity  0001 0010 0100 1000; #only available on FreeBSD and Linux<br \/>\n#worker_cpu_affinity  auto; #from version 1.9.10<\/p>\n<p>error_log logs\/error.log error;<\/p>\n<p>#if the module is compiled as a dynamic module and features relevant<br \/>\n#to RTMP are needed, the command below MUST be specified and MUST be<br \/>\n#located before events directive, otherwise the module won&#039;t be loaded<br \/>\n#or will be loaded unsuccessfully when NGINX is started<\/p>\n<p>#load_module modules\/ngx_http_flv_live_module.so;<\/p>\n<p>events {<br \/>\n    worker_connections  10240;<br \/>\n}<\/p>\n<p>http {<br \/>\n    include       mime.types;<br \/>\n    default_type  application\/octet-stream;<br \/>\n    sendfile        on;<br \/>\n   keepalive_timeout  65;<br \/>\n    server {<br \/>\n        listen       9000; #http-flv\u7684\u62c9\u6d41\u7aef\u53e3<br \/>\n        server_name  \u3010\u8fd9\u4e2a\u5730\u65b9\u5199\u4f60\u7684ip\u3001\u6216\u8005\u8bf4\u662f\u57df\u540d\u90fd\u662f\u53ef\u4ee5\u7684&#8211;\u3011; #http-flv\u7684\u62c9\u6d41ip<br \/>\n        location \/ {<br \/>\n            root   html;<br \/>\n            index  index.html index.htm;<br \/>\n       }<br \/>\n            #http-flv\u7684\u76f8\u5173\u914d\u7f6e<br \/>\n        location \/live{<br \/>\n                flv_live on; #\u6253\u5f00HTTP\u64ad\u653eFLV\u76f4\u64ad\u6d41\u529f\u80fd<br \/>\n                chunked_transfer_encoding  on;<br \/>\n                add_header &#039;Access-Control-Allow-Origin&#039; &#039;*&#039;;<br \/>\n                add_header &#039;Access-Control-Allow-Credentials&#039; &#039;true&#039;;<br \/>\n        }<br \/>\n        location \/hls{<br \/>\n                types {<br \/>\n                application\/vnd.apple.mpegurl m3u8;<br \/>\nvideo\/mp2t ts;<br \/>\n                 }<br \/>\n                 root \/usr\/local\/nginx\/html\/hls;<br \/>\n                 add_header &#039;Cache-Control&#039; &#039;no-cache&#039;;<br \/>\n        }<br \/>\n         location \/dash {<br \/>\n            root \/usr\/local\/nginx\/html\/dash;<br \/>\n            add_header &#039;Cache-Control&#039; &#039;no-cache&#039;;<br \/>\n        }<\/p>\n<p>         location \/stat {<br \/>\n            #configuration of push &amp; pull status<br \/>\n              rtmp_stat all;<br \/>\n              rtmp_stat_stylesheet stat.xsl;<br \/>\n         }<br \/>\n        location \/stat.xsl {<br \/>\n          root \/usr\/local\/nginx\/nginx-http-flv-module;<br \/>\n        }<\/p>\n<p>         location \/control {<br \/>\n            rtmp_control all; #configuration of control module of rtmp<br \/>\n}<\/p>\n<p>        error_page   500 502 503 504  \/50x.html;<br \/>\n        location &#061; \/50x.html {<br \/>\n            root   html;<br \/>\n        }<br \/>\n    }<\/p>\n<p>}<\/p>\n<p>rtmp_auto_push on;<br \/>\nrtmp_auto_push_reconnect 1s;<br \/>\nrtmp_socket_dir \/tmp;<\/p>\n<p>rtmp{<br \/>\n        out_queue 4096;<br \/>\n        out_cork 8;<br \/>\n        max_streams 128;<br \/>\n        timeout 15s;<br \/>\n        drop_idle_publisher 15s;<br \/>\n        log_interval 5s;<br \/>\n        log_size 1m;<br \/>\n        server{<br \/>\n            #\u63a8\u6d41\u7aef\u53e3<br \/>\n        listen 1935;<br \/>\n            #\u63a8\u6d41\u5e94\u7528\u540d\u79f0<br \/>\n         application myapp{<br \/>\n                 live on;<br \/>\n  record off;<br \/>\n                 gop_cache on;<br \/>\n          }<br \/>\n         application hls{<br \/>\n          live on;<br \/>\n          hls on;<br \/>\n          hls_path \/usr\/local\/nginx\/html\/hls;<br \/>\n          hls_fragment 1s;<br \/>\n                        hls_playlist_length 3s;<br \/>\n        }<br \/>\n         application dash{<br \/>\n           live on;<br \/>\n           dash on;<br \/>\n           dash_path \/usr\/local\/nginx\/html\/dash;<br \/>\n         }<\/p>\n<p>        }<br \/>\n}<\/p>\n<p id=\"u2e788531\">\u6d4b\u8bd5\u80fd\u4e0d\u80fd\u4f7f\u7528&#xff08;\u53ef\u7528\u8c03\u7528\u4e00\u4e2a\u53ef\u64ad\u653e\u7684rtsp\u5730\u5740&#xff09;<\/p>\n<p>ffmpeg -rtsp_transport tcp -i rtsp\u7684\u5730\u5740 -c:v libx264 -c:a aac -f flv -an rtmp:\/\/nginx\u7684ip:nginx\u6240\u914d\u7684\u7aef\u53e3\/myapp\/room<\/p>\n<p id=\"ua4d90bc7\">\u5982\u679c\u4f7f\u7528\u7684\u662f\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6&#xff0c;\u6b64\u65f6\u63a8\u6d41\u5e94\u5f801935\u7aef\u53e3\u63a8\u9001<\/p>\n<p id=\"u02ee3061\">\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u7684\u5730\u5740\u68c0\u67e5\u4e00\u4e0b\u6709\u6ca1\u6709\u753b\u9762<\/p>\n<p id=\"u80f356bc\">http:\/\/nginx\u7684ip:nginx\u8bbf\u95ee\u7684\u7aef\u53e39000\/live&#xff1f;port&#061;1935&#038;app&#061;myapp&#038;stream&#061;room<\/p>\n<p id=\"u9c812c03\">\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u7684\u662fmediamtx\u670d\u52a1\u5668\uff08\u539frtsp-simple-server\uff09\u7684\u914d\u7f6e\uff0c\u9644\u5e26\u4e00\u4e2a\u5173\u4e8enginx\u642d\u5efa\u53ef\u7528rtsp\u8f6c\u63a5\u4e3ahttp\u7aef\u53ef\u76f4\u63a5\u8bbf\u95ee\u7684\u65b9\u6848\u3002_rtsp-simple-server<\/p>\n","protected":false},"author":2,"featured_media":12924,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,44,747],"topic":[],"class_list":["post-12929","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-44","tag-747"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/12929.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u7684\u662fmediamtx\u670d\u52a1\u5668\uff08\u539frtsp-simple-server\uff09\u7684\u914d\u7f6e\uff0c\u9644\u5e26\u4e00\u4e2a\u5173\u4e8enginx\u642d\u5efa\u53ef\u7528rtsp\u8f6c\u63a5\u4e3ahttp\u7aef\u53ef\u76f4\u63a5\u8bbf\u95ee\u7684\u65b9\u6848\u3002_rtsp-simple-server\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12929.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T12:03:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f750c5c7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12929.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12929.html\",\"name\":\"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T12:03:02+00:00\",\"dateModified\":\"2025-04-18T12:03:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12929.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12929.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12929.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/12929.html","og_locale":"zh_CN","og_type":"article","og_title":"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb924\u6b21\uff0c\u70b9\u8d5e32\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u7684\u662fmediamtx\u670d\u52a1\u5668\uff08\u539frtsp-simple-server\uff09\u7684\u914d\u7f6e\uff0c\u9644\u5e26\u4e00\u4e2a\u5173\u4e8enginx\u642d\u5efa\u53ef\u7528rtsp\u8f6c\u63a5\u4e3ahttp\u7aef\u53ef\u76f4\u63a5\u8bbf\u95ee\u7684\u65b9\u6848\u3002_rtsp-simple-server","og_url":"https:\/\/www.wsisp.com\/helps\/12929.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T12:03:02+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418120301-68023f750c5c7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12929.html","url":"https:\/\/www.wsisp.com\/helps\/12929.html","name":"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T12:03:02+00:00","dateModified":"2025-04-18T12:03:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12929.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12929.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12929.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u642d\u5efa\u7b80\u6613\u7684rtsp\u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=12929"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12929\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/12924"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12929"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}