{"id":1077,"date":"2026-08-29T07:05:29","date_gmt":"2026-08-28T23:05:29","guid":{"rendered":"http:\/\/www.tantan.ink\/index.php\/2026\/08\/29\/mediamtx\/"},"modified":"2026-08-29T07:05:30","modified_gmt":"2026-08-28T23:05:30","slug":"mediamtx","status":"publish","type":"post","link":"https:\/\/www.tantan.ink\/index.php\/2026\/08\/29\/mediamtx\/","title":{"rendered":"MediaMTX\uff1a\u628a\u5bb6\u91cc\u7684\u76f4\u64ad\u6e90\u7edf\u4e00\u6536\u53e3\u6210 WebRTC\/HLS \u7684\u300c\u5a92\u4f53\u7f51\u5173\u300d"},"content":{"rendered":"<p>\u524d\u9635\u5b50\u60f3\u628a\u5bb6\u91cc\u51e0\u6761\u6765\u6e90\u4e0d\u592a\u7edf\u4e00\u7684\u76f4\u64ad\u4fe1\u53f7\u2014\u2014\u6709\u7684\u662f\u6444\u50cf\u5934\u7ed9\u7684 RTSP\uff0c\u6709\u7684\u662f\u7f51\u4e0a\u641c\u6765\u7684 HLS\uff0c\u518d\u6709\u5c31\u662f IPTV \u90a3\u79cd HTTP TS\u2014\u2014\u96c6\u4e2d\u5230\u4e00\u4e2a\u5730\u65b9\uff1a\u7535\u89c6\u4e0a\u80fd\u770b\u3001\u624b\u673a\u6d4f\u89c8\u5668\u70b9\u5f00\u5c31\u80fd\u64ad\u3001\u6700\u597d\u522b\u518d\u4e3a\u6bcf\u6761\u6d41\u5355\u72ec\u88c5\u4e00\u4e2a\u5ba2\u6237\u7aef\u3002\u8bd5\u8fc7\u51e0\u4e2a\u65b9\u6848\u90fd\u5dee\u70b9\u610f\u601d\uff0c\u76f4\u5230\u649e\u4e0a <strong>MediaMTX<\/strong>\uff0c\u624d\u89c9\u5f97\u300c\u8fd9\u4e8b\u5c31\u8be5\u8fd9\u4e48\u5e72\u300d\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/08\/mediamtx_home.jpg\" alt=\"MediaMTX \u5b98\u65b9\u6587\u6863\u9996\u9875\" \/><\/p>\n<h3>\u5b83\u5230\u5e95\u662f\u5565<\/h3>\n<p>\u5982\u679c\u8ba9\u6211\u7528\u4e00\u53e5\u8bdd\u8bb2\u660e\u767d\uff0c<strong>MediaMTX \u662f\u4e2a\u300c\u5a92\u4f53\u8def\u7531\u5668\u300d<\/strong>\uff0c\u4e0d\u662f\u300c\u5a92\u4f53\u8f6c\u6362\u5668\u300d\u3002\u5b83\u81ea\u5df1\u4e0d\u70e7 CPU \u91cd\u65b0\u7f16\u89e3\u7801\uff08transcoding\uff09\uff0c\u53ea\u505a\u4e00\u4ef6\u4e8b\uff1a\u628a\u4e00\u79cd\u534f\u8bae\u7684\u6d41\u62c6\u5305\uff0c\u6309\u53e6\u4e00\u79cd\u534f\u8bae\u91cd\u65b0\u6253\u5305\u9001\u8d70\u3002<strong>\u652f\u6301\u8bfb<\/strong>\u7684\u6709 Media-over-QUIC\u3001SRT\u3001WebRTC\u3001RTSP\u3001RTMP\u3001HLS\u3001MPEG-TS\u3001RTP\uff1b<strong>\u652f\u6301\u5199\u51fa\u53bb<\/strong>\u7684\u51e0\u4e4e\u4e00\u6837\u591a\u3002\u4efb\u4f55\u4e00\u6761\u6d41\u8fdb\u6765\uff0c\u53ef\u4ee5\u540c\u65f6\u88ab\u591a\u534f\u8bae\u5ba2\u6237\u7aef\u8ba2\u9605\u2014\u2014\u8fd9\u6b63\u662f\u6211\u60f3\u8981\u7684\u300c\u6536\u53e3\u300d\u3002<\/p>\n<p>\u5b83\u662f Go \u5199\u7684\u5355\u4e8c\u8fdb\u5236\uff0c\u96f6\u8fd0\u884c\u65f6\u4f9d\u8d56\uff0c<strong>Linux\/Windows\/macOS \u90fd\u8dd1<\/strong>\uff0c\u5b98\u65b9 Docker \u955c\u50cf\u4e5f\u5e38\u9a7b\u5728 Docker Hub\u3002\u622a\u81f3 2026-08-28\uff0cGitHub \u4e0a <strong>19.9k stars\u3001MIT \u534f\u8bae<\/strong>\uff0c\u6700\u65b0\u7a33\u5b9a\u7248\u662f <strong>v1.20.1<\/strong>\uff088 \u6708 18 \u65e5\u53d1\u5e03\uff09\uff0c\u4e3b\u5206\u652f\u6628\u5929\u8fd8\u6709\u63d0\u4ea4\uff0c\u6d3b\u8dc3\u5ea6\u5b8c\u5168\u4e0d\u7528\u62c5\u5fc3\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/08\/mediamtx_gh.jpg\" alt=\"MediaMTX GitHub \u4ed3\u5e93\u9875\" \/><\/p>\n<h3>\u4e09\u4ef6\u8ba9\u6211\u89c9\u5f97\u503c\u7684\u5c0f\u4e8b<\/h3>\n<p><strong>\u7b2c\u4e00\uff0c\u534f\u8bae\u81ea\u52a8\u8f6c\u6362\u3002<\/strong>\u628a\u90a3\u6761 RTSP \u6444\u50cf\u5934\u6e90\u63a8\u4e0a\u53bb\u4e4b\u540e\uff0c\u6d4f\u89c8\u5668\u80fd\u76f4\u63a5 WebRTC \u89c2\u770b\uff08\u5ef6\u8fdf\u8089\u773c\u53ef\u63a5\u53d7\uff09\uff0cVLC \u62c9 RTSP\uff0c\u7535\u89c6\u76d2\u5b50\u62c9 HLS\u2014\u2014\u4e00\u6761\u6e90\u4e09\u79cd\u6d88\u8d39\uff0c<strong>\u4e0d\u7528\u9884\u5148\u60f3\u6e05\u695a\u5ba2\u6237\u7aef\u662f\u4ec0\u4e48<\/strong>\u3002\u8fd9\u662f\u5b83\u533a\u522b\u4e8e\u666e\u901a\u6d41\u5a92\u4f53\u670d\u52a1\u5668\u7684\u6838\u5fc3\u80fd\u529b\u3002<\/p>\n<p><strong>\u7b2c\u4e8c\uff0calways-available \u6d41\u3002<\/strong>\u914d\u7f6e\u91cc\u628a\u67d0\u4e2a path \u6807\u6210 always-available\uff0c\u53d1\u5e03\u65b9\u4e0b\u7ebf\u540e\u5ba2\u6237\u7aef\u62c9\u6d41\u4f1a\u5148\u6536\u5230\u4e00\u5f20\u5360\u4f4d\u56fe\u50cf\uff08\u53ef\u81ea\u5b9a\u4e49\uff09\uff0c\u4e0d\u4f1a\u76f4\u63a5\u65ad\u8fde\u9ed1\u5c4f\u3002\u5bf9\u5076\u5c14\u8981\u300c\u4e00\u76f4\u6302\u7740\u3001\u4f46\u4e0d\u4e00\u5b9a\u6709\u4eba\u5728\u63a8\u300d\u7684\u573a\u666f\u7279\u522b\u53cb\u597d\uff0c\u6bd4\u5982\u6211\u90a3\u6761\u53ea\u5728\u6709\u4eba\u6309\u95e8\u94c3\u65f6\u624d\u63a8\u9001\u7684\u6444\u50cf\u5934\u3002<\/p>\n<p><strong>\u7b2c\u4e09\uff0c\u5f55\u5236\u662f\u771f\u00b7\u7701\u5fc3\u3002<\/strong>\u5f00 record: yes \u4e4b\u540e\uff0c\u5b83<strong>\u6309\u65f6\u95f4\u6bb5\u5207\u7247<\/strong>\u5199\u76d8\uff0c\u6587\u4ef6\u683c\u5f0f\u5728 fMP4 \u548c MPEG-TS \u4e4b\u95f4\u9009\u3002\u6211\u7528 fMP4 \u6bd4\u8f83\u591a\uff0c\u56e0\u4e3a\u6d4f\u89c8\u5668\u548c\u5927\u591a\u6570\u5de5\u5177\u90fd\u5403\u3002<strong>\u53ef\u4ee5\u914d recordDeleteAfter \u81ea\u52a8\u6e05\u65e7\u6587\u4ef6<\/strong>\uff0c\u907f\u514d\u4e00\u591c\u4e4b\u95f4\u628a NAS \u585e\u6ee1\u3002\u5b83\u4e0d\u505a\u8f6c\u7801\uff0c\u6240\u4ee5\u5f55\u5236\u51fa\u6765\u7684\u89c6\u9891\u7f16\u7801\u5c31\u662f\u6e90\u7aef\u7f16\u7801\u2014\u2014\u5982\u679c\u6e90\u662f H.264\/H.265\/AAC \u76f4\u63a5\u64ad\uff0c\u90a3\u5f55\u51fa\u6765\u5c31\u662f\u8fd9\u4e9b\uff0c\u4e0d\u7528\u518d\u8fc7\u4e00\u904d ffmpeg\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.tantan.ink\/wp-content\/uploads\/2026\/08\/mediamtx_publish.jpg\" alt=\"MediaMTX Publish streams \u6587\u6863\u9875\" \/><\/p>\n<h3>\u6211\u662f\u8fd9\u4e48\u628a\u5b83\u8dd1\u8d77\u6765\u7684<\/h3>\n<p>\u88c5\u5b83\u5c31\u4e00\u6761 Docker \u547d\u4ee4\u7684\u4e8b\uff1a<\/p>\n<pre><code>docker run --rm -it \n  -p 8554:8554 -p 1935:1935 -p 8888:8888 \n  -p 8889:8889 -p 8890:8890\/udp -p 8189:8189\/udp \n  -v \/path\/to\/mediamtx.yml:\/mediamtx.yml \n  bluenviron\/mediamtx:latest\n<\/code><\/pre>\n<p>\u7aef\u53e3\u770b\u7740\u591a\uff0c\u662f\u56e0\u4e3a\u4e0d\u540c\u534f\u8bae\u5404\u5360\u4e00\u4e2a\uff1a8554 \u9ed8\u8ba4 RTSP\u30011935 RTMP\u30018888 HLS\u30018889 WebRTC\u30018890\/udp \u662f SRT\u30018189\/udp \u662f RTP\u3002<strong>\u66b4\u9732\u4e4b\u524d\u60f3\u6e05\u695a\u54ea\u4e9b\u771f\u8981\u5bf9\u5916<\/strong>\uff0c\u5185\u7f51\u7528\u5c31\u53ea\u5f00 8554 + 8889 + 8888 \u4e09\u4e2a\u5c31\u591f\u4e86\uff0c\u5176\u4ed6\u5168 drop\u3002<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6 <code>mediamtx.yml<\/code> \u662f\u5b83\u63a7\u5236\u4e00\u5207\u7684\u5165\u53e3\u3002\u4e00\u6761\u5178\u578b\u7684 path \u957f\u8fd9\u6837\uff1a<\/p>\n<pre><code>paths:\n  cam_door:\n    source: rtsp:\/\/user:pass@192.168.x.x\/stream1\n    sourceOnDemand: yes\n    alwaysAvailable: yes\n    runOnReady: notify-telegram \"\u95e8\u94c3\u6444\u50cf\u5934\u5df2\u4e0a\u7ebf\"\n\n  4k_live:\n    source: publisher\n    record: yes\n    recordPath: .\/recordings\/%path\/%Y-%m-%d_%H-%M-%S\n    recordFormat: fmp4\n    recordSegmentDuration: 1h\n    recordDeleteAfter: 24h\n<\/code><\/pre>\n<p>\u7b2c\u4e00\u6761\u662f\u62c9\u73b0\u6709\u7684 RTSP \u8f6c\u591a\u534f\u8bae\u5206\u53d1\uff0c\u7b2c\u4e8c\u6761\u662f\u5141\u8bb8\u5916\u90e8\u63a8\u6d41\u4e0a\u6765\u3001\u81ea\u52a8\u5f55\u5236\u3001<strong>\u6309 1 \u5c0f\u65f6\u5207\u7247\u300124 \u5c0f\u65f6\u540e\u81ea\u52a8\u6e05<\/strong>\u3002<code>runOnReady<\/code> \u8fd9\u79cd hook \u8ba9\u6211\u5728\u6444\u50cf\u5934\u771f\u4e0a\u7ebf\u7684\u65f6\u5019\u7ed9\u81ea\u5df1\u53d1\u4e2a Telegram \u901a\u77e5\uff0c\u7701\u5f97\u53cd\u590d\u53bb WebUI \u770b\u3002<\/p>\n<p>\u60f3\u8fdc\u7a0b\u770b\u6bcf\u6761\u6d41\u7684\u72b6\u6001\uff08\u5728\u7ebf\u3001\u5ba2\u6237\u7aef\u6570\u3001\u7801\u7387\u3001\u5f55\u5236\u5927\u5c0f\uff09\uff0c<strong>8888 \u7aef\u53e3\u6709\u4e2a\u5185\u7f6e WebUI<\/strong>\u2014\u2014\u4e0d\u9700\u8981\u989d\u5916\u90e8\u7f72\u3002\u8fd8\u6709 Control API\uff08<code>\/control<\/code> \u8def\u5f84\u4e0b\u7684 HTTP \u63a5\u53e3\uff09\uff0c\u80fd\u811a\u672c\u5316\u67e5\u8be2\u548c\u8e22\u4eba\uff0c\u505a\u81ea\u52a8\u5316\u65f6\u7279\u522b\u987a\u624b\u3002<\/p>\n<h3>\u8e29\u5230\u7684\u51e0\u4e2a\u5751<\/h3>\n<p><strong>\u6d4f\u89c8\u5668\u770b WebRTC \u9700\u8981 HTTPS<\/strong>\uff0c\u6216\u8005\u7528 localhost \u8bbf\u95ee\u3002\u6211\u5bb6 NAS \u8d70\u7684\u662f\u53cd\u4ee3\uff0c\u7edf\u4e00\u5728\u7f51\u5173\u90a3\u5c42\u63a5\u4e86\u4e2a\u8bc1\u4e66\u8f6c\u53d1\u624d\u89e3\u51b3\u2014\u2014\u4f60\u4e5f\u53ef\u4ee5\u7528 Caddy\/Nginx \u7ed9 MediaMTX \u5957 TLS\uff0c<strong>\u522b\u76f4\u63a5\u628a\u5b83\u6254\u5230\u516c\u7f51 8889<\/strong>\u3002<\/p>\n<p><strong>\u5b83\u771f\u7684\u4e0d\u8f6c\u7801<\/strong>\u3002\u6211\u4e00\u5f00\u59cb\u4ee5\u4e3a\u80fd\u50cf ffmpeg \u4e00\u6837\u628a H.265 \u76f4\u64ad\u6e90\u300c\u987a\u4fbf\u300d\u7ed9\u8001\u7535\u89c6\u8f6c\u6210 H.264\uff0c<strong>\u4e0d\u884c<\/strong>\u3002MediaMTX \u53ea\u505a\u534f\u8bae\u5c42\u642c\u8fd0\uff0c\u7f16\u7801\u8f6c\u6362\u8981\u4e48\u6e90\u7aef\u641e\u5b9a\uff0c\u8981\u4e48\u5728\u5b83\u524d\u9762\/\u540e\u9762\u6302 ffmpeg\u3002\u5982\u679c\u4f60\u7684\u5ba2\u6237\u7aef\u786c\u89e3 H.265 \u5403\u529b\uff0c\u5f97\u8001\u8001\u5b9e\u5b9e\u8d77 ffmpeg \u8f6c\u4e00\u9053\u3002<\/p>\n<p><strong>\u8ba4\u8bc1\u8981\u81ea\u5df1\u5f00<\/strong>\u3002\u9ed8\u8ba4\u6240\u6709 path \u90fd\u4e0d\u9700\u8981\u8d26\u53f7\u5bc6\u7801\uff0c<strong>\u516c\u7f51\u5f00\u4e4b\u524d\u4e00\u5b9a\u8981\u914d internal \/ HTTP \/ JWT \u4e09\u79cd\u4e4b\u4e00<\/strong>\uff0c\u6700\u7b80\u5355\u662f internal \u5199\u6b7b\u7528\u6237\u5bc6\u7801\u8868\u3002\u6211\u5077\u61d2\u5185\u7f51\u88f8\u8dd1\u4e86\u4e00\u6bb5\u65f6\u95f4\uff0c\u76f4\u5230\u67d0\u5929\u5728\u8def\u7531\u5668\u65e5\u5fd7\u91cc\u770b\u89c1\u5916\u9762\u6709\u4eba\u626b 8554 \u624d\u8865\u4e0a\u3002<\/p>\n<p><strong>fMP4 \u5f55\u5236\u7684\u5c0f\u5751<\/strong>\uff1a\u5f55\u50cf\u662f\u6309 <code>recordPartDuration<\/code> \u62fc\u8d77\u6765\u7684\uff0c<strong>\u7cfb\u7edf\u5d29\u6e83\u65f6\u6700\u540e\u4e00\u4e2a part \u4f1a\u4e22<\/strong>\u3002\u5bf9\u5bb6\u7528\u573a\u666f\u65e0\u6240\u8c13\uff0c\u5bf9\u6b63\u7ecf\u505a\u5f55\u50cf\u5f52\u6863\u7684\u9700\u8981\u81ea\u5df1\u7528 hook + rclone \u4e4b\u7c7b\u540c\u6b65\u5230\u522b\u5904\u3002\u5b98\u65b9\u6587\u6863\u91cc\u7684\u300cRemote upload\u300d\u4e00\u8282\u5c31\u662f\u5e72\u8fd9\u4e2a\u7684\u3002<\/p>\n<h3>\u9002\u5408\u8c01\u3001\u4e0d\u9002\u5408\u8c01<\/h3>\n<p><strong>\u9002\u5408<\/strong>\uff1a\u5bb6\u91cc\u6709\u51e0\u8def\u5f02\u6784\u6765\u6e90\uff08\u6444\u50cf\u5934\u3001IPTV\u3001\u81ea\u5efa\u76f4\u64ad\uff09\u60f3\u7edf\u4e00\u5165\u53e3\u7684\u4eba\uff1b\u60f3\u7ed9\u8001\u76d1\u63a7\u5934\u52a0 WebRTC \u6d4f\u89c8\u5668\u89c2\u770b\u80fd\u529b\u7684\u4eba\uff1b\u60f3\u4f4e\u8d44\u6e90\u8dd1\u4e00\u4e2a\u80fd\u5f55\u80fd\u64ad\u7684\u5b9e\u9a8c\u6027\u5c0f\u5e73\u53f0\u7684\u4eba\u2014\u2014\u5355\u4e8c\u8fdb\u5236\u3001\u5185\u5b58\u51e0\u5341\u5146\u3001CPU \u57fa\u672c\u53ea\u8dd1\u534f\u8bae\u89e3\u6790\uff0c<strong>\u6811\u8393\u6d3e 4B \u90fd\u8dd1\u5f97\u52a8<\/strong>\u3002<\/p>\n<p><strong>\u4e0d\u592a\u9002\u5408<\/strong>\uff1a\u9700\u8981\u300c\u70b9\u64ad\u7535\u5f71\u5e93\u300d\u7684\u4eba\u2014\u2014\u5b83\u53ea\u505a\u5b9e\u65f6\u6d41\u548c\u5f55\u5236\u56de\u653e\uff0c\u4e0d\u662f Jellyfin \/ Plex \u90a3\u79cd\u5e26\u522e\u524a\u7684\u5a92\u4f53\u5e93\uff1b\u9700\u8981\u7ed9\u8001\u7535\u89c6\u5f3a\u5236 H.264 \u8f93\u51fa\u7684\u4eba\u2014\u2014\u524d\u9762\u8bf4\u8fc7\uff0c\u5b83\u4e0d\u8f6c\u7801\u3002<\/p>\n<p>GitHub: <a href=\"https:\/\/github.com\/bluenviron\/mediamtx\" target=\"_blank\" rel=\"noopener\">bluenviron\/mediamtx<\/a> \uff5c \u6587\u6863: <a href=\"https:\/\/mediamtx.org\/docs\/kickoff\/introduction\" target=\"_blank\" rel=\"noopener\">mediamtx.org<\/a> \uff5c \u534f\u8bae: MIT \uff5c \u5f53\u524d\u7a33\u5b9a\u7248: v1.20.1\uff082026-08-18\uff09\u3002<strong>Docker \u955c\u50cf\u3001Linux\/macOS\/Windows \u4e8c\u8fdb\u5236\u3001Homebrew tap \u90fd\u6709<\/strong>\uff0c\u6309\u9700\u53d6\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5355\u4e8c\u8fdb\u5236\u3001\u96f6\u4f9d\u8d56\u3001\u534f\u8bae\u5168\uff1aMediaMTX \u7528\u300c\u5a92\u4f53\u8def\u7531\u5668\u300d\u7684\u601d\u8def\u628a RTSP\/HLS\/HTTP TS \u8fd9\u4e9b\u5f02\u6784\u6e90\u7edf\u4e00\u8f6c\u6362\u6210 WebRTC\/HLS\uff0c\u6d4f\u89c8\u5668\u548c\u7535\u89c6\u90fd\u80fd\u770b\u3002\u81ea\u5e26\u5f55\u5236\u3001WebUI\u3001Control API\uff0c\u5bb6\u7528 1GB \u5185\u5b58\u90fd\u8dd1\u5f97\u52a8\u3002<\/p>\n","protected":false},"author":2,"featured_media":1081,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[164,10],"tags":[249,246,248,203,247,250,16,251],"class_list":["post-1077","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-selfhost","category-software","tag-hls","tag-mediamtx","tag-rtsp","tag-webrtc","tag-247","tag-250","tag-16","tag-251"],"_links":{"self":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/comments?post=1077"}],"version-history":[{"count":1,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1077\/revisions"}],"predecessor-version":[{"id":1082,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/posts\/1077\/revisions\/1082"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/media\/1081"}],"wp:attachment":[{"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/media?parent=1077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/categories?post=1077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tantan.ink\/index.php\/wp-json\/wp\/v2\/tags?post=1077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}