{"id":595,"date":"2023-07-02T16:51:51","date_gmt":"2023-07-02T08:51:51","guid":{"rendered":"https:\/\/harson.co\/?p=595"},"modified":"2023-07-05T21:41:28","modified_gmt":"2023-07-05T13:41:28","slug":"live-stream-server-on-docker","status":"publish","type":"post","link":"https:\/\/harson.co\/index.php\/2023\/07\/02\/live-stream-server-on-docker\/","title":{"rendered":"Live Stream Server In Docker"},"content":{"rendered":"<h2 class=\"entry-title\">\u7528Docker\u90e8\u7f72RTMP\u63a8\u6d41\u670d\u52a1\u5668<\/h2>\n<p><a href=\"https:\/\/harson.co\/index.php\/2020\/03\/01\/dockerfile-for-rtmp\/\">\u4e09\u5e74\u524d<\/a>\u7528CentOS\u7684\u955c\u50cf\u6784\u5efa\u8fc7RTMP Nginx\u7684\u63a8\u6d41\u670d\u52a1\u5668\uff0c\u524d\u4e00\u6bb5\u65f6\u95f4\u518d\u6784\u5efa\u7684\u65f6\u5019\u53d1\u73b0\u901f\u5ea6\u5f88\u6162\uff0c\u800c\u4e14\u955c\u50cf\u5f88\u5927\uff0c\u8003\u8651\u5230CentOS\u90fd\u5df2\u7ecf\u505c\u6b62\u7ef4\u62a4\u4e86\uff0c\u4e8e\u662f\u6700\u8fd1\u7528Ubuntu22.04LTS\u955c\u50cf\u5347\u7ea7\u4e00\u4e0b\uff0c\u4f18\u5316\u5b8c\u6210\u540e\u955c\u50cf\u5927\u5c0f\u964d\u4e86\u4e00\u534a\u8fd8\u8981\u591a\u4e00\u70b9\uff0c\u6784\u5efa\u901f\u5ea6\u4e5f\u5feb\u4e86\u5f88\u591a\u3002<\/p>\n<p><strong>\u4f18\u5316\u524d\uff1a<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">ubuntu@VM-8-3-ubuntu:~$ sudo docker images\r\nREPOSITORY         TAG          IMAGE ID       CREATED         SIZE\r\nrtmp               v1           0bcf5aea6d3b   38 hours ago    1.16GB\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u540e\uff1a<\/strong><\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">harson@harson-virtual-machine:~\/Desktop\/rtmp$ sudo docker images\r\nREPOSITORY        TAG         IMAGE ID       CREATED         SIZE\r\nrtmp              v2          b5e94e7c3ab9   9 minutes ago   454MB<\/code><\/pre>\n<h2><strong>\u6784\u5efa\u8fc7\u7a0b<\/strong><\/h2>\n<p><em>\u4f9d\u8d56\u6587\u4ef6\u5728\u6587\u672b<\/em><\/p>\n<p>\u5c06dockerfile\u4ee5\u53ca\u4f9d\u8d56\u653e\u5728\u540c\u4e00\u76ee\u5f55\u540e\uff0c\u8fd0\u884c<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">sudo docker build -t rtmp:v2 .<\/code><\/pre>\n<p>\u6210\u529f\u6784\u5efa\u5b8c\u540e\u8fd0\u884c\u5bb9\u5668<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">sudo docker run -p 7935:7935 -p 7938:7938 -d rtmp:v2<\/code><\/pre>\n<p>\u5176\u4e2d7935\u662fhttp\u7aef\u53e3\uff0c7938\u662fRTMP\u670d\u52a1\u7aef\u53e3\uff0c\u7aef\u53e3\u5b9a\u4e49\u5728 <em>nginx.conf\u00a0<\/em>\uff0c\u53ef\u6309\u9700\u4fee\u6539<\/p>\n<h2>\u4f7f\u7528OBS\u63a8\u6d41<\/h2>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/harson.co\/wp-content\/uploads\/2023\/07\/6EMG9PDFOCXMMDNO.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-596\" data-original=\"https:\/\/harson.co\/wp-content\/uploads\/2023\/07\/6EMG9PDFOCXMMDNO.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" width=\"997\" height=\"769\"  sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/div><\/p>\n<p>\u5730\u5740\u683c\u5f0f\u4e3a\uff1a<\/p>\n<p>rtmp:\/\/192.168.76.129:7935\/myapp\/streamname<\/p>\n<p>\u5176\u4e2dmyapp\u548cstreamname\u5728 <em>nginx.conf <\/em>\u4e2d\u5b9a\u4e49\uff0c\u53ef\u6309\u9700\u4fee\u6539<\/p>\n<h2>\u4f7f\u7528FLV.js\u89c2\u770b\u76f4\u64ad<\/h2>\n<p>\u901a\u8fc7\u8bbf\u95eehtml\u6587\u4ef6\u6765\u89c2\u770b\u76f4\u64ad\uff0cFLV.js\u4e2d\u7684\u5730\u5740\u9700\u8981\u4fee\u6539\u6210\u76f4\u64ad\u670d\u52a1\u5668\u7684\u5730\u5740<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"\">&lt;!doctype html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=\"utf-8\"&gt;\r\n     &lt;script src=\"https:\/\/cdn.bootcss.com\/flv.js\/1.6.0\/flv.js\"&gt;&lt;\/script&gt;\r\n    &lt;title&gt;Live&lt;\/title&gt;\r\n    &lt;style&gt;\r\n\t\tvideo{\r\n\t\t\twidth: 1024px;\r\n\t\t\theight: 768px;\r\n\t\t}\r\n\r\n    &lt;\/style&gt;\r\n&lt;\/head&gt;\r\n    &lt;div&gt;\r\n        &lt;video id=\"videoElement\" class=\"centeredVideo\" controls autoplay&gt;\r\n            Your browser is too old which doesn't support HTML5 video.\r\n        &lt;\/video&gt;\r\n    &lt;\/div&gt;\r\n&lt;script&gt;\r\n    if (flvjs.isSupported()) {\r\n        var videoElement = document.getElementById('videoElement');\r\n        var flvPlayer = flvjs.createPlayer({\r\n            type: 'flv',\r\n            url: 'http:\/\/192.168.76.129:7938\/live?port=7935&amp;app=myapp&amp;stream=streamname'\r\n        });\r\n        flvPlayer.attachMediaElement(videoElement);\r\n        flvPlayer.load();\r\n        flvPlayer.play();\r\n    }\r\n&lt;\/script&gt;\r\n&lt;\/html&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2>\u4f9d\u8d56\u6587\u4ef6<\/h2>\n<p><a href=\"http:\/\/index.harson.co\/source\/dockerfile\">dockerfile<\/a><\/p>\n<p><a href=\"http:\/\/index.harson.co\/source\/nginx-1.22.1.tar.gz\">nginx-1.22.1.tar.gz<\/a><\/p>\n<p><a href=\"http:\/\/index.harson.co\/source\/nginx-http-flv-module-1.2.11.tar.gz\">nginx-http-flv-module-1.2.11.tar.gz<\/a><\/p>\n<p><a href=\"http:\/\/index.harson.co\/source\/nginx.conf\">nginx.conf<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7528Docker\u90e8\u7f72RTMP\u63a8\u6d41\u670d\u52a1\u5668 \u4e09\u5e74\u524d\u7528CentOS\u7684\u955c\u50cf\u6784\u5efa\u8fc7RTMP Nginx\u7684\u63a8\u6d41\u670d\u52a1\u5668\uff0c\u524d\u4e00\u6bb5 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":6,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":603,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/595\/revisions\/603"}],"wp:attachment":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}