{"id":1664,"date":"2024-11-10T09:56:07","date_gmt":"2024-11-10T01:56:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1664\/"},"modified":"2024-11-10T09:56:07","modified_gmt":"2024-11-10T01:56:07","slug":"%e4%bd%bf%e7%94%a8-html-canvas-%e7%94%9f%e6%88%90%e9%ab%98%e6%b8%85%e6%99%b0%e5%ba%a6%e8%a7%86%e9%a2%91%ef%bc%9a%e5%a6%82%e4%bd%95%e7%94%a8-recordrtc-js-%e6%88%96-gif-js-%e5%af%bc%e5%87%ba%e5%8a%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1664\/","title":{"rendered":"\u4f7f\u7528 HTML Canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff1a\u5982\u4f55\u7528 RecordRTC.js \u6216 gif.js \u5bfc\u51fa\u52a8\u6001\u56fe\u8868\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173052884058061.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 HTML Canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff1a\u5982\u4f55\u7528 RecordRTC.js \u6216 gif.js \u5bfc\u51fa\u52a8\u6001\u56fe\u8868\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528 HTML Canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff1a\u5982\u4f55\u7528 RecordRTC.js \u6216 gif.js \u5bfc\u51fa\u52a8\u6001\u56fe\u8868\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528 html canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891<\/strong><\/p>\n<p>\u4e3a\u4e86\u751f\u6210\u52a8\u6001\u56fe\u8868\u7684\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff0c\u4e00\u79cd\u65b9\u6cd5\u662f\u5229\u7528 html canvas\u3002\u901a\u5e38\uff0c\u5c4f\u5e55\u5f55\u5236\u4ea7\u751f\u7684\u89c6\u9891\u8d28\u91cf\u8f83\u5dee\u3002\u7136\u800c\uff0c\u901a\u8fc7\u4f7f\u7528 canvas \u5e76\u63d0\u9ad8\u8bbe\u5907\u50cf\u7d20\u6bd4\uff0c\u53ef\u4ee5\u663e\u7740\u63d0\u9ad8\u6e05\u6670\u5ea6\u3002 <\/p>\n<p><strong>\u4f7f\u7528 recordrtc.js<\/strong><\/p>\n<p>\u751f\u6210\u89c6\u9891\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 recordrtc.js \u63d2\u4ef6\u3002\u8fd9\u4e2a\u63d2\u4ef6\u96c6\u6210\u4e86 html2canvas\uff0c\u56e0\u6b64\u9700\u8981\u540c\u65f6\u5f15\u5165\u8be5\u63d2\u4ef6\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528recordrtc.js \u5bfc\u51fa\u89c6\u9891\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>&lt;script&gt;\n    \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n    settimeout(function(){\n        \/\/ \u5f00\u59cb\u5f55\u5236\n        exporttovideo(5000);\n    }, 500);\n\n    function exporttovideo(time) {\n        \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n        recordrtc.startrecording();\n        \n        settimeout(function(){\n            \/\/ \u505c\u6b62\u5f55\u5236\n            recordrtc.stoprecording(function(videourl) {\n                \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n            });\n        }, time);\n    }\n&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5bfc\u51fagif<\/strong><\/p>\n<p>\u53e6\u4e00\u4e2a\u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\u7684\u65b9\u6cd5\u662f\u4f7f\u7528gif.js \u63d2\u4ef6\u5bfc\u51fagif \u3002\u4ee5\u4e0b\u662f\u4f7f\u7528gif.js \u5bfc\u51fagif \u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;script&gt;\n    \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n    setTimeout(function(){\n        \/\/ \u5f00\u59cb\u5f55\u5236 GIF\n        exportToGif(5000);\n    }, 20);\n\n    function exportToGif(time) {\n        \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n        loop();\n    }\n\n    \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n\n    gif.on('finished', function(blob) {\n        \/\/ ... \u7701\u7565\u5176\u4ed6\u4ee3\u7801 ...\n    });\n\n    loop()\n&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u5229\u7528html canvas \u5e76\u4f7f\u7528recordrtc.js \u6216gif.js \u63d2\u4ef6\uff0c\u53ef\u4ee5\u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u7684\u89c6\u9891\u6216gif\uff0c\u4ece\u800c\u6ee1\u8db3\u5b9e\u65f6\u52a8\u6001\u56fe\u8868\u7684\u53ef\u89c6\u5316\u9700\u6c42\u3002 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4f7f\u7528 HTML Canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff1a\u5982\u4f55\u7528 RecordRTC.js \u6216 gif.js \u5bfc\u51fa\u52a8\u6001\u56fe\u8868\uff1f\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>\u4f7f\u7528 html canvas \u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891 \u4e3a\u4e86\u751f\u6210\u52a8\u6001\u56fe\u8868\u7684\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\uff0c\u4e00\u79cd\u65b9\u6cd5\u662f\u5229\u7528 html canvas\u3002\u901a\u5e38\uff0c\u5c4f\u5e55\u5f55\u5236\u4ea7\u751f\u7684\u89c6\u9891\u8d28\u91cf\u8f83\u5dee\u3002\u7136\u800c\uff0c\u901a\u8fc7\u4f7f\u7528 canvas \u5e76\u63d0\u9ad8\u8bbe\u5907\u50cf\u7d20\u6bd4\uff0c\u53ef\u4ee5\u663e\u7740\u63d0\u9ad8\u6e05\u6670\u5ea6\u3002 \u4f7f\u7528 recordrtc.js \u751f\u6210\u89c6\u9891\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 recordrtc.js \u63d2\u4ef6\u3002\u8fd9\u4e2a\u63d2\u4ef6\u96c6\u6210\u4e86 html2canvas\uff0c\u56e0\u6b64\u9700\u8981\u540c\u65f6\u5f15\u5165\u8be5\u63d2\u4ef6\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528recordrtc.js \u5bfc\u51fa\u89c6\u9891\u7684\u793a\u4f8b\u4ee3\u7801\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b &lt;script&gt; \/\/ &#8230; \u7701\u7565\u5176\u4ed6\u4ee3\u7801 &#8230; settimeout(function(){ \/\/ \u5f00\u59cb\u5f55\u5236 exporttovideo(5000); }, 500); function exporttovideo(time) { \/\/ &#8230; \u7701\u7565\u5176\u4ed6\u4ee3\u7801 &#8230; recordrtc.startrecording(); settimeout(function(){ \/\/ \u505c\u6b62\u5f55\u5236 recordrtc.stoprecording(function(videourl) { \/\/ &#8230; \u7701\u7565\u5176\u4ed6\u4ee3\u7801 &#8230; }); }, time); } &lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 \u5bfc\u51fagif \u53e6\u4e00\u4e2a\u751f\u6210\u9ad8\u6e05\u6670\u5ea6\u89c6\u9891\u7684\u65b9\u6cd5\u662f\u4f7f\u7528gif.js \u63d2\u4ef6\u5bfc\u51fagif \u3002\u4ee5\u4e0b\u662f\u4f7f\u7528gif.js [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1664","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1664","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=1664"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1664\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}