{"id":18332,"date":"2024-11-18T15:22:27","date_gmt":"2024-11-18T07:22:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18332\/"},"modified":"2024-11-18T15:22:27","modified_gmt":"2024-11-18T07:22:27","slug":"nginx%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aertmp","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18332\/","title":{"rendered":"nginx\u5982\u4f55\u914d\u7f6ertmp"},"content":{"rendered":"<blockquote><p>\n  \u5728 nginx \u4e2d\u914d\u7f6e rtmp \u7684\u6b65\u9aa4\u6709\uff1a\u5b89\u88c5 rtmp \u6a21\u5757\u7f16\u8f91 nginx \u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0 rtmp \u914d\u7f6e\u521b\u5efa\u7528\u4e8e\u63a8\u9001\u548c\u62c9\u53d6\u6d41\u7684 rtmp \u6d41\u6e90\u91cd\u542f nginx\u4f7f\u7528 vlc \u64ad\u653e\u5668\u9a8c\u8bc1\u914d\u7f6e\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/06\/2024060615421888390.jpg\" class=\"aligncenter\" title=\"nginx\u5982\u4f55\u914d\u7f6ertmp\u63d2\u56fe\" alt=\"nginx\u5982\u4f55\u914d\u7f6ertmp\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Nginx \u4e2d\u914d\u7f6e RTMP<\/strong><\/p>\n<p>\u4e3a\u4e86\u5728 Nginx \u4e2d\u914d\u7f6e RTMP\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<p><strong>1. \u5b89\u88c5 RTMP \u6a21\u5757<\/strong><\/p>\n<pre>apt-get install nginx-module-rtmp<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u914d\u7f6e Nginx<\/strong><\/p>\n<p>\u5728 Nginx \u914d\u7f6e\u6587\u4ef6 \/etc\/\/nginx.conf \u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>rtmp {\n    server {\n        listen 1935;\n        chunk_size 4096;\n\n        application live {\n            push  \"push.stream\";\n            pull  \"live.stream\";\n            live  on;\n        }\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u521b\u5efa RTMP \u6d41\u6e90<\/strong><\/p>\n<p>\u521b\u5efa\u4e24\u4e2a\u6d41\u6e90\uff0c\u4e00\u4e2a\u7528\u4e8e\u63a8\u9001\u6d41\uff0c\u4e00\u4e2a\u7528\u4e8e\u62c9\u53d6\u6d41\uff1a<\/p>\n<pre># \u63a8\u9001\u6d41\u6e90\nffmpeg -re -i input.mp4 -vcodec libx264 -acodec aac -f flv rtmp:\/\/localhost:1935\/live\/push.stream\n\n# \u62c9\u53d6\u6d41\u6e90\nffmpeg -i rtmp:\/\/localhost:1935\/live\/live.stream output.mp4<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u91cd\u542f Nginx<\/strong><\/p>\n<pre>systemctl restart nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>5. \u9a8c\u8bc1\u914d\u7f6e<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528 VLC \u5a92\u4f53\u64ad\u653e\u5668\u8fde\u63a5\u5230 RTMP \u6d41\u6e90\u4ee5\u9a8c\u8bc1\u914d\u7f6e\uff1a<\/p>\n<ul>\n<li>\u63a8\u9001\u6d41\uff1artmp:\/\/localhost:1935\/live\/push.stream<\/li>\n<li>\u62c9\u53d6\u6d41\uff1artmp:\/\/localhost:1935\/live\/live.stream<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u914d\u7f6ertmp\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 nginx \u4e2d\u914d\u7f6e rtmp \u7684\u6b65\u9aa4\u6709\uff1a\u5b89\u88c5 rtmp \u6a21\u5757\u7f16\u8f91 nginx \u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0 rtmp \u914d\u7f6e\u521b\u5efa\u7528\u4e8e\u63a8\u9001\u548c\u62c9\u53d6\u6d41\u7684 rtmp \u6d41\u6e90\u91cd\u542f nginx\u4f7f\u7528 vlc \u64ad\u653e\u5668\u9a8c\u8bc1\u914d\u7f6e \u5982\u4f55\u5728 Nginx \u4e2d\u914d\u7f6e RTMP \u4e3a\u4e86\u5728 Nginx \u4e2d\u914d\u7f6e RTMP\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a 1. \u5b89\u88c5 RTMP \u6a21\u5757 apt-get install nginx-module-rtmp \u767b\u5f55\u540e\u590d\u5236 2. \u914d\u7f6e Nginx \u5728 Nginx \u914d\u7f6e\u6587\u4ef6 \/etc\/\/nginx.conf \u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a rtmp { server { listen 1935; chunk_size 4096; application live { push &#8220;push.stream&#8221;; pull &#8220;live.stream&#8221;; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-18332","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=18332"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18332\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}