{"id":7926,"date":"2020-03-05T18:24:37","date_gmt":"2020-03-05T10:24:37","guid":{"rendered":"https:\/\/sdeno.com\/?p=7926"},"modified":"2020-03-05T18:32:11","modified_gmt":"2020-03-05T10:32:11","slug":"%e4%bd%bf%e7%94%a8flv-js%e5%81%9a%e7%9b%b4%e6%92%ad","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=7926","title":{"rendered":"\u4f7f\u7528flv.js\u505a\u76f4\u64ad"},"content":{"rendered":"<p><a href=\"https:\/\/github.com\/gwuhaolin\/blog\/issues\/3\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/gwuhaolin\/blog\/issues\/3<\/a><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000009695424\" target=\"_blank\" rel=\"noopener\">https:\/\/segmentfault.com\/a\/1190000009695424<\/a><\/p>\n<p><a href=\"https:\/\/wuhaolin.cn\/2017\/05\/17\/%E4%BD%BF%E7%94%A8flv.js%E5%81%9A%E7%9B%B4%E6%92%AD\/\" target=\"_blank\" rel=\"noopener\">https:\/\/wuhaolin.cn\/2017\/05\/17\/%E4%BD%BF%E7%94%A8flv.js%E5%81%9A%E7%9B%B4%E6%92%AD\/<\/a><\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u5728\u8fd9\u4e2a\u65f6\u5019\u63a2\u7d22flv.js\u505a\u76f4\u64ad\u5462\uff1f\u539f\u56e0\u5728\u4e8e\u5404\u5927\u6d4f\u89c8\u5668\u5382\u5546\u5df2\u7ecf\u9ed8\u8ba4\u7981\u7528Flash\uff0c\u4e4b\u524d\u5e38\u89c1\u7684Flash\u76f4\u64ad\u65b9\u6848\u9700\u8981\u7528\u6237\u540c\u610f\u4f7f\u7528Flash\u540e\u624d\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u76f4\u64ad\u529f\u80fd\uff0c\u8fd9\u6837\u7684\u7528\u6237\u4f53\u9a8c\u5f88\u81f4\u547d\u3002<\/p>\n<p>\u5728\u4ecb\u7ecdflv.js\u4e4b\u524d\u5148\u4ecb\u7ecd\u4e0b\u5e38\u89c1\u7684\u76f4\u64ad\u534f\u8bae\u4ee5\u53ca\u7ed9\u51fa\u6211\u5bf9\u5b83\u4eec\u7684\u5ef6\u8fdf\u4e0e\u6027\u80fd\u6240\u505a\u7684\u6d4b\u8bd5\u5f97\u51fa\u7684\u6570\u636e\u3002<br \/>\n\u5982\u679c\u4f60\u770b\u7684\u5f88\u5403\u529b\u53ef\u4ee5\u5148\u4e86\u89e3\u4e0b\u97f3\u89c6\u9891\u6280\u672f\u7684\u4e00\u4e9b\u57fa\u7840\u6982\u5ff5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5e38\u89c1\u76f4\u64ad\u534f\u8bae<\/p>\n<p><strong>RTMP<\/strong>: \u5e95\u5c42\u57fa\u4e8eTCP\uff0c\u5728\u6d4f\u89c8\u5668\u7aef\u4f9d\u8d56Flash\u3002<br \/>\n<strong>HTTP-FLV<\/strong>: \u57fa\u4e8eHTTP\u6d41\u5f0fIO\u4f20\u8f93FLV\uff0c\u4f9d\u8d56\u6d4f\u89c8\u5668\u652f\u6301\u64ad\u653eFLV\u3002<br \/>\n<strong>WebSocket-FLV<\/strong>: \u57fa\u4e8eWebSocket\u4f20\u8f93FLV\uff0c\u4f9d\u8d56\u6d4f\u89c8\u5668\u652f\u6301\u64ad\u653eFLV\u3002WebSocket\u5efa\u7acb\u5728HTTP\u4e4b\u4e0a\uff0c\u5efa\u7acbWebSocket\u8fde\u63a5\u524d\u8fd8\u8981\u5148\u5efa\u7acbHTTP\u8fde\u63a5\u3002<br \/>\n<strong>HLS<\/strong>: Http Live Streaming\uff0c\u82f9\u679c\u63d0\u51fa\u57fa\u4e8eHTTP\u7684\u6d41\u5a92\u4f53\u4f20\u8f93\u534f\u8bae\u3002HTML5\u53ef\u4ee5\u76f4\u63a5\u6253\u5f00\u64ad\u653e\u3002<br \/>\n<strong>RTP<\/strong>: \u57fa\u4e8eUDP\uff0c\u5ef6\u8fdf1\u79d2\uff0c\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u5e38\u89c1\u76f4\u64ad\u534f\u8bae\u5ef6\u8fdf\u4e0e\u6027\u80fd\u6570\u636e<sub><sup>\u4ee5\u4e0b\u6570\u636e\u53ea\u505a\u5bf9\u6bd4\u53c2\u8003<\/sup><\/sub><\/h4>\n<table>\n<thead>\n<tr>\n<th>\u4f20\u8f93\u534f\u8bae<\/th>\n<th>\u64ad\u653e\u5668<\/th>\n<th>\u5ef6\u8fdf<\/th>\n<th>\u5185\u5b58<\/th>\n<th>CPU<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>RTMP<\/td>\n<td>Flash<\/td>\n<td>1s<\/td>\n<td>430M<\/td>\n<td>11%<\/td>\n<\/tr>\n<tr>\n<td>HTTP-FLV<\/td>\n<td>Video<\/td>\n<td>1s<\/td>\n<td>310M<\/td>\n<td>4.4%<\/td>\n<\/tr>\n<tr>\n<td>HLS<\/td>\n<td>Video<\/td>\n<td>20s<\/td>\n<td>205M<\/td>\n<td>3%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u652f\u6301\u6d4f\u89c8\u5668\u7684\u534f\u8bae\u91cc\uff0c\u5ef6\u8fdf\u6392\u5e8f\u662f\uff1a<br \/>\n<strong>RTMP = HTTP-FLV = WebSocket-FLV &lt; HLS<\/strong><br \/>\n\u800c\u6027\u80fd\u6392\u5e8f\u6070\u597d\u76f8\u53cd\uff1a<br \/>\n<strong>RTMP &gt; HTTP-FLV = WebSocket-FLV &gt; HLS<\/strong><br \/>\n\u4e5f\u5c31\u662f\u8bf4\u5ef6\u8fdf\u5c0f\u7684\u6027\u80fd\u4e0d\u597d\u3002<\/p>\n<p>\u53ef\u4ee5\u770b\u51fa\u5728\u6d4f\u89c8\u5668\u91cc\u505a\u76f4\u64ad\uff0c\u4f7f\u7528HTTP-FLV\u534f\u8bae\u662f\u4e0d\u9519\u7684\uff0c\u6027\u80fd\u4f18\u4e8eRTMP+Flash\uff0c\u5ef6\u8fdf\u53ef\u4ee5\u505a\u5230\u548cRTMP+Flash\u4e00\u6837\u751a\u81f3\u66f4\u597d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h6>flv.js \u7b80\u4ecb<\/h6>\n<p>flv.js\u662f\u6765\u81eaBilibli\u7684\u5f00\u6e90\u9879\u76ee\u3002\u5b83\u89e3\u6790FLV\u6587\u4ef6\u5582\u7ed9\u539f\u751fHTML5 Video\u6807\u7b7e\u64ad\u653e\u97f3\u89c6\u9891\u6570\u636e\uff0c\u4f7f\u6d4f\u89c8\u5668\u5728\u4e0d\u501f\u52a9Flash\u7684\u60c5\u51b5\u4e0b\u64ad\u653eFLV\u6210\u4e3a\u53ef\u80fd\u3002<\/p>\n<h6>flv.js \u4f18\u52bf<\/h6>\n<ul>\n<li>\u7531\u4e8e\u6d4f\u89c8\u5668\u5bf9\u539f\u751fVideo\u6807\u7b7e\u91c7\u7528\u4e86\u786c\u4ef6\u52a0\u901f\uff0c\u6027\u80fd\u5f88\u597d\uff0c\u652f\u6301\u9ad8\u6e05\u3002<\/li>\n<li>\u540c\u65f6\u652f\u6301\u5f55\u64ad\u548c\u76f4\u64ad<\/li>\n<li>\u53bb\u6389\u5bf9Flash\u7684\u4f9d\u8d56<\/li>\n<\/ul>\n<h6>flv.js \u9650\u5236<\/h6>\n<ul>\n<li>FLV\u91cc\u6240\u5305\u542b\u7684\u89c6\u9891\u7f16\u7801\u5fc5\u987b\u662f<code>H.264<\/code>\uff0c\u97f3\u9891\u7f16\u7801\u5fc5\u987b\u662f<code>AAC<\/code>\u6216<code>MP3<\/code>\uff0c IE11\u548cEdge\u6d4f\u89c8\u5668\u4e0d\u652f\u6301MP3\u97f3\u9891\u7f16\u7801\uff0c\u6240\u4ee5FLV\u91cc\u91c7\u7528\u7684\u7f16\u7801\u6700\u597d\u662fH.264+AAC\uff0c\u8fd9\u4e2a\u8ba9\u97f3\u89c6\u9891\u670d\u52a1\u517c\u5bb9\u4e0d\u662f\u95ee\u9898\u3002<\/li>\n<li>\u5bf9\u4e8e\u5f55\u64ad\uff0c\u4f9d\u8d56\u00a0<code>\u539f\u751fHTML5 Video\u6807\u7b7e<\/code>\u00a0\u548c\u00a0<a href=\"https:\/\/w3c.github.io\/media-source\/\" rel=\"nofollow\">Media Source Extensions<\/a>\u00a0API<\/li>\n<li>\u5bf9\u4e8e\u76f4\u64ad\uff0c\u4f9d\u8d56\u5f55\u64ad\u6240\u9700\u8981\u7684\u64ad\u653e\u6280\u672f\uff0c\u540c\u65f6\u4f9d\u8d56\u00a0<code>HTTP FLV<\/code>\u00a0\u6216\u8005\u00a0<code>WebSocket<\/code>\u00a0\u4e2d\u7684\u4e00\u79cd\u534f\u8bae\u6765\u4f20\u8f93FLV\u3002\u5176\u4e2d<code>HTTP FLV<\/code>\u9700\u901a\u8fc7\u6d41\u5f0fIO\u53bb\u62c9\u53d6\u6570\u636e\uff0c\u652f\u6301\u6d41\u5f0fIO\u7684\u6709<a href=\"https:\/\/fetch.spec.whatwg.org\/\" rel=\"nofollow\">fetch<\/a>\u6216\u8005<a href=\"https:\/\/streams.spec.whatwg.org\/\" rel=\"nofollow\">stream<\/a><\/li>\n<li><code>flv.min.js<\/code>\u00a0\u6587\u4ef6\u5927\u5c0f 164Kb\uff0cgzip\u540e 35.5Kb\uff0cflash\u64ad\u653e\u5668gzip\u540e\u5dee\u4e0d\u591a\u4e5f\u662f\u8fd9\u4e48\u5927\u3002<\/li>\n<li>\u7531\u4e8e\u4f9d\u8d56<code>Media Source Extensions<\/code>\uff0c\u76ee\u524d\u6240\u6709iOS\u548cAndroid4.4.4\u4ee5\u4e0b\u91cc\u7684\u6d4f\u89c8\u5668\u90fd\u4e0d\u652f\u6301\uff0c\u4e5f\u5c31\u662f\u8bf4\u76ee\u524d\u5bf9\u4e8e\u79fb\u52a8\u7aefflv.js\u57fa\u672c\u662f\u4e0d\u80fd\u7528\u7684\u3002<\/li>\n<\/ul>\n<h6>flv.js\u4f9d\u8d56\u7684\u6d4f\u89c8\u5668\u7279\u6027\u517c\u5bb9\u5217\u8868<\/h6>\n<ul>\n<li><a href=\"http:\/\/caniuse.com\/#feat=webm\" rel=\"nofollow\">HTML5 Video<\/a><\/li>\n<li><a href=\"http:\/\/caniuse.com\/#feat=mediasource\" rel=\"nofollow\">Media Source Extensions<\/a><\/li>\n<li><a href=\"http:\/\/caniuse.com\/#feat=websockets\" rel=\"nofollow\">WebSocket<\/a><\/li>\n<li>HTTP FLV:\u00a0<a href=\"http:\/\/caniuse.com\/#feat=fetch\" rel=\"nofollow\">fetch<\/a>\u00a0\u6216\u00a0<a href=\"http:\/\/caniuse.com\/#feat=http-live-streaming\" rel=\"nofollow\">stream<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h6>flv.js \u539f\u7406<\/h6>\n<p>flv.js\u53ea\u505a\u4e86\u4e00\u4ef6\u4e8b\uff0c\u5728\u83b7\u53d6\u5230FLV\u683c\u5f0f\u7684\u97f3\u89c6\u9891\u6570\u636e\u540e\u901a\u8fc7\u539f\u751f\u7684JS\u53bb\u89e3\u7801FLV\u6570\u636e\uff0c\u518d\u901a\u8fc7<a href=\"https:\/\/w3c.github.io\/media-source\/\" rel=\"nofollow\">Media Source Extensions<\/a>\u00a0API \u5582\u7ed9\u539f\u751fHTML5 Video\u6807\u7b7e\u3002(HTML5 \u539f\u751f\u4ec5\u652f\u6301\u64ad\u653e mp4\/webm \u683c\u5f0f\uff0c\u4e0d\u652f\u6301 FLV)<\/p>\n<p>flv.js \u4e3a\u4ec0\u4e48\u8981\u7ed5\u4e00\u5708\uff0c\u4ece\u670d\u52a1\u5668\u83b7\u53d6FLV\u518d\u89e3\u7801\u8f6c\u6362\u540e\u518d\u5582\u7ed9Video\u6807\u7b7e\u5462\uff1f\u539f\u56e0\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u517c\u5bb9\u76ee\u524d\u7684\u76f4\u64ad\u65b9\u6848\uff1a\u76ee\u524d\u5927\u591a\u6570\u76f4\u64ad\u65b9\u6848\u7684\u97f3\u89c6\u9891\u670d\u52a1\u90fd\u662f\u91c7\u7528FLV\u5bb9\u5668\u683c\u5f0f\u4f20\u8f93\u97f3\u89c6\u9891\u6570\u636e\u3002<\/li>\n<li>FLV\u5bb9\u5668\u683c\u5f0f\u76f8\u6bd4\u4e8eMP4\u683c\u5f0f\u66f4\u52a0\u7b80\u5355\uff0c\u89e3\u6790\u8d77\u6765\u66f4\u5feb\u66f4\u65b9\u4fbf\u3002<\/li>\n<\/ol>\n<h6>flv.js\u517c\u5bb9\u65b9\u6848<\/h6>\n<p>\u7531\u4e8e\u76ee\u524dflv.js\u517c\u5bb9\u6027\u8fd8\u4e0d\u662f\u5f88\u597d\uff0c\u8981\u7528\u5728\u4ea7\u54c1\u4e2d\u5fc5\u8981\u8981\u517c\u987e\u5230\u4e0d\u652f\u6301flv.js\u7684\u6d4f\u89c8\u5668\u3002\u517c\u5bb9\u65b9\u6848\u5982\u4e0b\uff1a<\/p>\n<h6>PC\u7aef<\/h6>\n<ol>\n<li>\u4f18\u5148\u4f7f\u7528 HTTP-FLV\uff0c\u56e0\u4e3a\u5b83\u5ef6\u8fdf\u5c0f\uff0c\u6027\u80fd\u4e5f\u4e0d\u5dee1080P\u90fd\u5f88\u6d41\u7545\u3002<\/li>\n<li>\u4e0d\u652f\u6301 flv.js \u5c31\u4f7f\u7528 Flash\u64ad\u653e\u5668\u64ad RTMP \u6d41\u3002Flash\u517c\u5bb9\u6027\u5f88\u597d\uff0c\u4f46\u662f\u6027\u80fd\u5dee\u9ed8\u8ba4\u88ab\u5f88\u591a\u6d4f\u89c8\u5668\u7981\u7528\u3002<\/li>\n<li>\u4e0d\u60f3\u7528Flash\u517c\u5bb9\u4e5f\u53ef\u4ee5\u7528HLS\uff0c\u4f46\u662fPC\u7aef\u53ea\u6709Safari\u652f\u6301HLS<\/li>\n<\/ol>\n<h6>\u79fb\u52a8\u7aef<\/h6>\n<ol>\n<li>\u4f18\u5148\u4f7f\u7528 HTTP-FLV\uff0c\u56e0\u4e3a\u5b83\u5ef6\u8fdf\u5c0f\uff0c\u652f\u6301HTTP-FLV\u7684\u8bbe\u5907\u6027\u80fd\u8fd0\u884c flv.js \u8db3\u591f\u4e86\u3002<\/li>\n<li>\u4e0d\u652f\u6301 flv.js \u5c31\u4f7f\u7528 HLS\uff0c\u4f46\u662f HLS\u5ef6\u8fdf\u975e\u5e38\u5927\u3002<\/li>\n<li>HLS \u4e5f\u4e0d\u652f\u6301\u5c31\u6ca1\u6cd5\u76f4\u64ad\u4e86\uff0c\u56e0\u4e3a\u79fb\u52a8\u7aef\u90fd\u4e0d\u652f\u6301Flash\u3002<\/li>\n<\/ol>\n<h6>flv.js\u5b9e\u6218<\/h6>\n<p>\u8bf4\u4e86\u8fd9\u4e48\u591a\u4ecb\u7ecd\u4e0e\u539f\u7406\uff0c\u63a5\u4e0b\u6765\u6559\u5927\u5bb6\u5982\u4f55\u7528flv.js\u642d\u5efa\u4e00\u4e2a\u5b8c\u6574\u7684\u76f4\u64ad\u7cfb\u7edf\u3002<br \/>\n\u6211\u5df2\u7ecf\u642d\u5efa\u597d\u4e86<a href=\"http:\/\/rawgit.com\/gwuhaolin\/reflv\/gh-pages\/live.html\" rel=\"nofollow\">\u4e00\u4e2ademo<\/a>\u53ef\u4ee5\u4f9b\u5927\u5bb6\u4f53\u9a8c\u3002<\/p>\n<h6>\u642d\u5efa\u97f3\u89c6\u9891\u670d\u52a1<\/h6>\n<p>\u4e3b\u64ad\u63a8\u6d41\u5230\u97f3\u89c6\u9891\u670d\u52a1\uff0c\u97f3\u89c6\u9891\u670d\u52a1\u518d\u8f6c\u53d1\u7ed9\u6240\u6709\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u3002\u4e3a\u4e86\u8ba9\u4f60\u5feb\u901f\u642d\u5efa\u670d\u52a1\u63a8\u8350\u6211\u7528go\u8bed\u8a00\u5b9e\u73b0\u7684<a href=\"https:\/\/github.com\/gwuhaolin\/livego\">livego<\/a>\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u8fd0\u884c\u5728\u4efb\u4f55\u64cd\u4f5c\u7cfb\u7edf\u4e0a\uff0c\u5bf9Golang\u611f\u5174\u8da3\uff1f\u8bf7\u770b<a href=\"http:\/\/go.wuhaolin.cn\/\" rel=\"nofollow\">Golang \u4e2d\u6587\u5b66\u4e60\u8d44\u6599\u6c47\u603b<\/a>\u3002<\/p>\n<ol>\n<li><a href=\"https:\/\/github.com\/gwuhaolin\/livego\/releases\">\u4e0b\u8f7dlivego<\/a>\uff0c\u6ce8\u610f\u9009\u5bf9\u4f60\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u4f4d\u6570\u3002<\/li>\n<li>\u89e3\u538b\uff0c\u6267\u884c<code>livego<\/code>\uff0c\u670d\u52a1\u5c31\u542f\u52a8\u597d\u4e86\u3002\u5b83\u4f1a\u542f\u52a8RTMP(1935\u7aef\u53e3)\u670d\u52a1\u7528\u4e8e\u4e3b\u64ad\u63a8\u6d41\uff0c\u4ee5\u53caHTTP-FLV(7001\u7aef\u53e3)\u670d\u52a1\u7528\u4e8e\u64ad\u653e\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/gwuhaolin\/blog\/issues\/3 https:\/\/segm [&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":[],"class_list":["post-7926","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/7926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7926"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/7926\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}