{"id":75951,"date":"2024-03-01T18:48:34","date_gmt":"2024-03-01T10:48:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=75951"},"modified":"2024-03-01T18:49:03","modified_gmt":"2024-03-01T10:49:03","slug":"go%e8%af%ad%e8%a8%80%e4%b8%ad%e7%9a%84%e9%9f%b3%e8%a7%86%e9%a2%91%e5%a4%84%e7%90%86%e6%8a%80%e6%9c%af","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/75951.html","title":{"rendered":"Go\u8bed\u8a00\u4e2d\u7684\u97f3\u89c6\u9891\u5904\u7406\u6280\u672f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone size-full wp-image-75952\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/03\/generated_00-42.png?x-oss-process=image\/auto-orient,1\/format,webp\" width=\"600\" height=\"342\" alt=\"Go\u8bed\u8a00\u4e2d\u7684\u97f3\u89c6\u9891\u5904\u7406\u6280\u672f\" \/><\/p>\n<p><strong>Go\u8bed\u8a00\u56e0\u5176\u7b80\u6d01\u7684\u8bed\u6cd5\u7ed3\u6784\u3001\u5353\u8d8a\u7684\u5e76\u53d1\u5904\u7406\u80fd\u529b\u3001\u4ee5\u53ca\u9ad8\u6548\u7684\u6027\u80fd\u8868\u73b0\uff0c\u5728\u97f3\u89c6\u9891\u5904\u7406\u9886\u57df\u4e5f\u5c55\u73b0\u51fa\u4e86\u5f3a\u5927\u7684\u751f\u547d\u529b\u3002\u5728Go\u8bed\u8a00\u4e2d\u5904\u7406\u97f3\u89c6\u9891\u6280\u672f\u4e3b\u8981\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a\u683c\u5f0f\u89e3\u6790\u4e0e\u8f6c\u7801\u3001\u97f3\u89c6\u9891\u6570\u636e\u7684\u91c7\u96c6\u4e0e\u5904\u7406\u3001\u6d41\u5a92\u4f53\u670d\u52a1\u5f00\u53d1\u3001\u4ee5\u53ca\u97f3\u89c6\u9891\u5185\u5bb9\u7684\u5206\u53d1\u548c\u4f18\u5316\u3002<\/strong><\/p>\n<p>\u7279\u522b\u5730\uff0cGo\u8bed\u8a00\u4e2d\u5904\u7406\u97f3\u89c6\u9891\u7684\u6838\u5fc3\u5728\u4e8e<strong>\u683c\u5f0f\u89e3\u6790\u4e0e\u8f6c\u7801<\/strong>\u3002\u683c\u5f0f\u89e3\u6790\u662f\u6307\u5bf9\u97f3\u89c6\u9891\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u89e3\u538b\u548c\u89e3\u6790\uff0c\u6765\u83b7\u53d6\u97f3\u89c6\u9891\u7684\u5143\u6570\u636e\u4ee5\u53ca\u5a92\u4f53\u6570\u636e\u6d41\u3002\u8f6c\u7801\u5219\u662f\u5c06\u97f3\u89c6\u9891\u6587\u4ef6\u4ece\u4e00\u79cd\u683c\u5f0f\u8f6c\u6362\u5230\u53e6\u4e00\u79cd\u683c\u5f0f\uff0c\u8fd9\u5728\u53d1\u5e03\u5230\u4e0d\u540c\u5e73\u53f0\u6216\u8fdb\u884c\u517c\u5bb9\u6027\u5904\u7406\u65f6\u5c24\u4e3a\u91cd\u8981\u3002Go\u8bed\u8a00\u901a\u8fc7\u8c03\u7528\u5e95\u5c42\u7f16\u89e3\u7801\u5e93\uff08\u4f8b\u5982FFmpeg\uff09\u53ef\u4ee5\u6709\u6548\u5730\u5b8c\u6210\u8fd9\u4e00\u4efb\u52a1\uff0c\u540c\u65f6\u4fdd\u6301\u4e86\u8f83\u9ad8\u7684\u5904\u7406\u6027\u80fd\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5728Go\u8bed\u8a00\u4e2d\u5982\u4f55\u8fdb\u884c\u9ad8\u6548\u7684\u97f3\u89c6\u9891\u5904\u7406\u3002<\/p>\n<p><strong>\u4e00\u3001\u97f3\u89c6\u9891\u5904\u7406\u7684\u57fa\u7840\uff1a\u683c\u5f0f\u89e3\u6790\u4e0e\u8f6c\u7801<\/strong><\/p>\n<p>\u97f3\u89c6\u9891\u6587\u4ef6\u5305\u542b\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u4eec\u9700\u8981\u7279\u5b9a\u7684\u683c\u5f0f\u6765\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\u6d41\uff0c\u6bd4\u5982\u97f3\u9891\u6d41\u3001\u89c6\u9891\u6d41\u3002<strong>\u683c\u5f0f\u89e3\u6790<\/strong>\u56e0\u6b64\u6210\u4e86\u97f3\u89c6\u9891\u5904\u7406\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u73af\u3002Go\u8bed\u8a00\u53ef\u4ee5\u901a\u8fc7\u7b2c\u4e09\u65b9\u5e93\u4f8b\u5982`goav`\u6216`ffmpeg-go`\u5bf9\u97f3\u89c6\u9891\u683c\u5f0f\u8fdb\u884c\u89e3\u6790\u3002\u8fd9\u4e9b\u5e93\u901a\u5e38\u662f\u5bf9FFmpeg\u8fd9\u6837\u7684\u5f3a\u5927\u7f16\u89e3\u7801\u5de5\u5177\u7684\u5c01\u88c5\u3002<\/p>\n<p>\u5728<strong>\u8f6c\u7801<\/strong>\u65b9\u9762\uff0cGo\u8bed\u8a00\u53ef\u4ee5\u5229\u7528\u4e0a\u8ff0\u5e93\u6765\u5b9e\u73b0\u97f3\u89c6\u9891\u683c\u5f0f\u7684\u8f6c\u6362\u3002\u8fd9\u4e0d\u4ec5\u5305\u62ec\u538b\u7f29\u683c\u5f0f\u7684\u8f6c\u6362\uff0c\u8fd8\u5305\u62ec\u7f16\u7801\u53c2\u6570\u7684\u8c03\u6574\uff0c\u5982\u6bd4\u7279\u7387\u3001\u5206\u8fa8\u7387\u7b49\u3002<\/p>\n<p><strong>\u4e8c\u3001\u97f3\u89c6\u9891\u6570\u636e\u7684\u91c7\u96c6\u4e0e\u5904\u7406<\/strong><\/p>\n<p>\u91c7\u96c6\u662f\u97f3\u89c6\u9891\u5904\u7406\u7684\u7b2c\u4e00\u6b65\u3002\u5728Go\u8bed\u8a00\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u63a5\u53e3\u6216\u4f7f\u7528\u4e13\u95e8\u7684\u5e93\u6765\u5b9e\u73b0\u97f3\u89c6\u9891\u7684\u91c7\u96c6\u3002<strong>\u6570\u636e\u5904\u7406<\/strong>\u5219\u6d89\u53ca\u5230\u97f3\u89c6\u9891\u4fe1\u53f7\u7684\u589e\u5f3a\u3001\u8fc7\u6ee4\u3001\u6df7\u6d41\u7b49\u590d\u6742\u64cd\u4f5c\u3002<\/p>\n<p>Go\u8bed\u8a00\u4e2d\u7528\u4e8e\u97f3\u89c6\u9891\u5904\u7406\u7684\u5e93\u6709`portaudio`\u3001`go-microphone`\u7b49\uff0c\u5b83\u4eec\u53ef\u4ee5\u5b9e\u73b0\u5bf9\u97f3\u9891\u7684\u5b9e\u65f6\u91c7\u96c6\u3002\u5728\u89c6\u9891\u91c7\u96c6\u65b9\u9762\uff0c\u867d\u7136Go\u8bed\u8a00\u6ca1\u6709\u5982Python\u4e2dOpenCV\u90a3\u6837\u7684\u5168\u529f\u80fd\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u4f46\u53ef\u4ee5\u4f7f\u7528`webcam`\u7b49\u5e93\u5bf9\u89c6\u9891\u6570\u636e\u8fdb\u884c\u6293\u53d6\u3002<\/p>\n<p><strong>\u4e09\u3001\u6d41\u5a92\u4f53\u670d\u52a1\u7684\u5f00\u53d1<\/strong><\/p>\n<p>\u968f\u7740\u76f4\u64ad\u7b49\u5e94\u7528\u7684\u5174\u8d77\uff0c\u6d41\u5a92\u4f53\u670d\u52a1\u6210\u4e3a\u97f3\u89c6\u9891\u5904\u7406\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u5e94\u7528\u573a\u666f\u3002\u5728Go\u8bed\u8a00\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528`rtmp`\u3001`hls`\u7b49\u534f\u8bae\u6765\u5f00\u53d1\u6d41\u5a92\u4f53\u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u5b9e\u65f6\u89c6\u9891\u6570\u636e\u7684\u4f20\u8f93\u3002<\/p>\n<p>Go\u7684<strong>\u5e76\u53d1\u5904\u7406\u80fd\u529b<\/strong>\u7279\u522b\u9002\u5408\u5904\u7406\u591a\u5ba2\u6237\u7aef\u7684\u6d41\u5a92\u4f53\u670d\u52a1\u3002\u901a\u8fc7Goroutine\u548cChannel\u7b49\u673a\u5236\uff0cGo\u8bed\u8a00\u80fd\u591f\u9ad8\u6548\u5730\u7ba1\u7406\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u548c\u6570\u636e\u5206\u53d1\u3002<\/p>\n<p><strong>\u56db\u3001\u97f3\u89c6\u9891\u5185\u5bb9\u7684\u5206\u53d1\u548c\u4f18\u5316<\/strong><\/p>\n<p>\u9664\u4e86\u5236\u4f5c\u548c\u5904\u7406\u97f3\u89c6\u9891\u5185\u5bb9\uff0c\u5176\u5206\u53d1\u548c\u4f18\u5316\u4e5f\u662f\u4e0d\u53ef\u5ffd\u89c6\u7684\u73af\u8282\u3002Go\u8bed\u8a00\u5728\u8fd9\u65b9\u9762\u540c\u6837\u8868\u73b0\u51fa\u8272\u3002\u5b83\u53ef\u4ee5\u7ed3\u5408\u73b0\u4ee3\u7684\u4e91\u5b58\u50a8\u670d\u52a1\uff0c\u6bd4\u5982AWS\u7684S3\u3001Google Cloud Storage\uff0c\u8fdb\u884c\u5927\u89c4\u6a21\u7684\u97f3\u89c6\u9891\u5185\u5bb9\u5206\u53d1\u3002<\/p>\n<p>\u5728\u5185\u5bb9\u4f20\u9012\u7f51\u7edc\uff08CDN\uff09\u7684\u6784\u5efa\u8fc7\u7a0b\u4e2d\uff0cGo\u8bed\u8a00\u4e5f\u80fd\u53d1\u6325\u5176\u4f18\u52bf\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<strong>\u5feb\u901f\u7f13\u5b58\u7b97\u6cd5\u548c\u4f18\u5316\u540e\u7684\u7f51\u7edc\u534f\u8bae\u6808<\/strong>\uff0cGo\u670d\u52a1\u80fd\u591f\u5feb\u901f\u54cd\u5e94\u5168\u7403\u8303\u56f4\u5185\u7684\u7528\u6237\u8bf7\u6c42\uff0c\u5927\u5927\u964d\u4f4e\u5ef6\u8fdf\u3002<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u9010\u6b65\u6df1\u5165\u63a2\u8ba8Go\u8bed\u8a00\u5728\u97f3\u89c6\u9891\u9886\u57df\u7684\u5e94\u7528\uff0c\u7279\u522b\u662f\u5b83\u5728\u683c\u5f0f\u89e3\u6790\u4e0e\u8f6c\u7801\u3001\u97f3\u89c6\u9891\u6570\u636e\u7684\u91c7\u96c6\u4e0e\u5904\u7406\u3001\u6d41\u5a92\u4f53\u670d\u52a1\u7684\u5f00\u53d1\u3001\u4ee5\u53ca\u97f3\u89c6\u9891\u5185\u5bb9\u7684\u5206\u53d1\u548c\u4f18\u5316\u56db\u4e2a\u65b9\u9762\u7684\u6280\u672f\u7ec6\u8282\u548c\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u4ec0\u4e48\u662fGo\u8bed\u8a00\u7684\u97f3\u89c6\u9891\u5904\u7406\u6280\u672f\uff1f<\/strong><br \/>\nGo\u8bed\u8a00\u5728\u97f3\u89c6\u9891\u5904\u7406\u65b9\u9762\u6709\u4e30\u5bcc\u7684\u751f\u6001\u7cfb\u7edf\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u5e93\u548c\u5de5\u5177\uff0c\u7528\u4e8e\u5904\u7406\u97f3\u9891\u548c\u89c6\u9891\u6570\u636e\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u97f3\u89c6\u9891\u7f16\u89e3\u7801\u3001\u526a\u8f91\u3001\u8f6c\u7801\u3001\u6d41\u5a92\u4f53\u5904\u7406\u7b49\u529f\u80fd\u3002<\/p>\n<p><strong>Go\u8bed\u8a00\u4e2d\u6709\u54ea\u4e9b\u5e38\u7528\u7684\u97f3\u89c6\u9891\u5904\u7406\u5e93\uff1f<\/strong><br \/>\nGo\u8bed\u8a00\u4e2d\u6709\u4e00\u4e9b\u5e38\u7528\u7684\u97f3\u89c6\u9891\u5904\u7406\u5e93\uff0c\u4f8b\u5982\uff1affmpeg\u3001gstreamer\u3001libav\u7b49\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u63a5\u53e3\uff0c\u65b9\u4fbf\u5f00\u53d1\u8005\u8fdb\u884c\u97f3\u89c6\u9891\u5904\u7406\u3002\u540c\u65f6\uff0cGo\u8bed\u8a00\u8fd8\u6709\u4e00\u4e9b\u9488\u5bf9\u7279\u5b9a\u529f\u80fd\u7684\u5e93\uff0c\u5982\u97f3\u9891\u7f16\u89e3\u7801\u3001\u89c6\u9891\u526a\u8f91\u3001\u6d41\u5a92\u4f53\u63a8\u9001\u7b49\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9879\u76ee\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u5e93\u6765\u4f7f\u7528\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Go\u8bed\u8a00\u4e2d\u5b9e\u73b0\u97f3\u89c6\u9891\u6d41\u5a92\u4f53\u5904\u7406\uff1f<\/strong><br \/>\n\u8981\u5728Go\u8bed\u8a00\u4e2d\u5b9e\u73b0\u97f3\u89c6\u9891\u6d41\u5a92\u4f53\u5904\u7406\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u4e13\u95e8\u7684\u5e93\uff0c\u6bd4\u5982\uff1aFFmpeg\u3001GStreamer\u3001Pion\u7b49\u3002\u901a\u8fc7\u8fd9\u4e9b\u5e93\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u5b9e\u73b0\u97f3\u89c6\u9891\u7684\u6d41\u5a92\u4f53\u63a8\u9001\u3001\u62c9\u53d6\u3001\u8f6c\u7801\u7b49\u529f\u80fd\u3002\u540c\u65f6\uff0c\u7ed3\u5408\u7f51\u7edc\u7f16\u7a0b\u77e5\u8bc6\uff0c\u53ef\u4ee5\u6784\u5efa\u51fa\u5b8c\u6574\u7684\u97f3\u89c6\u9891\u6d41\u5a92\u4f53\u5904\u7406\u7cfb\u7edf\uff0c\u5b9e\u73b0\u5b9e\u65f6\u7684\u97f3\u89c6\u9891\u4f20\u8f93\u548c\u5904\u7406\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Go\u8bed\u8a00\u56e0\u5176\u7b80\u6d01\u7684\u8bed\u6cd5\u7ed3\u6784\u3001\u5353\u8d8a\u7684\u5e76\u53d1\u5904\u7406\u80fd\u529b\u3001\u4ee5\u53ca\u9ad8\u6548\u7684\u6027\u80fd\u8868\u73b0\uff0c\u5728\u97f3\u89c6\u9891\u5904\u7406\u9886\u57df\u4e5f\u5c55\u73b0\u51fa\u4e86\u5f3a\u5927\u7684\u751f\u547d\u529b\u3002\u5728 [&hellip;]","protected":false},"author":1,"featured_media":75954,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/75951"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=75951"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/75951\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/75954"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=75951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=75951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=75951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}