{"id":11043,"date":"2023-11-15T00:37:18","date_gmt":"2023-11-14T16:37:18","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11043"},"modified":"2023-11-15T11:25:44","modified_gmt":"2023-11-15T03:25:44","slug":"mp4box-js-webcodecs-mp4-canvas","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/11\/mp4box-js-webcodecs-mp4-canvas\/","title":{"rendered":"mp4box.js\u52a0WebCodecs \u89e3\u7801MP4\u89c6\u9891\u5e27\u5e76\u6e32\u67d3"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11043\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=11043<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202311-mp4-encode.jpg';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202311\/bear-lake.jpg\" width=\"420\" height=\"270\" alt=\"\u5c01\u9762\u56fe \u98ce\u666f \u718a\uff0c\u6811\u6728\uff0c\u9ad8\u5c71\uff0c\u6e56\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u5df2\u6709\u7684\u5b66\u4e60\u8d44\u6e90<\/h3>\n<p>WebCodecs API\u89e3\u7801GIF\u52a8\u56fe\u4e4b\u524d\u5df2\u7ecf\u64b0\u6587\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u8bbf\u95ee\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/05\/js-imagedecoder-api-gif\/\">\u4f7f\u7528ImageDecoder API\u8ba9GIF\u56fe\u7247\u6682\u505c\u64ad\u653e<\/a>\u201d\u3002<\/p>\n<p>\u7136\u540e\u4f7f\u7528Webcodecs API\u7f16\u7801\u5e26\u97f3\u9891\u7684MP4\u6587\u4ef6\u5728<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2023\/05\/mp4-video-api-webcodecs-webm\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\u4e2d\u6709\u4ecb\u7ecd\u8fc7\u4e86\uff0c\u6f14\u793a\u9875\u9762\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202305\/mp4-muxer-canvas-to-video-demo.php\" rel=\"noopener\" target=\"_blank\">canvas\u5e8f\u5217+MP3\u97f3\u9891\u5b9e\u73b0mp4\u89c6\u9891demo<\/a><\/p>\n<p>\u5e76\u4e14\u57fa\u4e8e\u4e0a\u9762\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u6211\u628a\u4e4b\u524d\u5f00\u53d1\u7684APNG\u5728\u7ebf\u751f\u6210\u5de5\u5177\u7a0d\u5fae\u6269\u5c55\u4e86\u4e0b\uff0c\u540c\u65f6\u652f\u6301\u751f\u6210MP4\u6587\u4ef6\u5e76\u4e0b\u8f7d\uff0c\u6709\u5174\u8da3\u53ef\u4ee5\u72e0\u51fb\u8fd9\u91cc\u4f53\u9a8c\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/sp\/apng\/\" rel=\"noopener\" target=\"_blank\">APNG\/MP4\u5728\u7ebf\u5408\u6210\u4e0b\u8f7d\u5de5\u5177<\/a><\/p>\n<p>OK\uff0c\u597d\uff0c\u6700\u8fd1\u53c8\u9047\u5230\u65b0\u9700\u6c42\uff0c\u9700\u8981\u5bf9MP4\u89c6\u9891\u8fdb\u884c\u89e3\u7801\u3002<\/p>\n<p>\u5173\u4e8eMP4\u89c6\u9891\u89e3\u7801\uff0c\u4e4b\u524d\u6709\u4ecb\u7ecd\u8fc7JSMpeg\u548cBroadway\u4e24\u4e2a\u9879\u76ee\uff0c\u4e0d\u8fc7\u81ea\u5df1<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/04\/js-video-decode-jsmpeg-broadway\/\">demo\u5e76\u6ca1\u6709\u8dd1\u901a<\/a>\uff0c\u5c31\u6ca1\u6709\u6df1\u7a76\u3002<\/p>\n<p>\u8fd9\u4e00\u56de\uff0c\u7531\u4e8e\u6709\u4e86webcodecs API\uff0c\u6211\u786e\u4fe1\u4e00\u5b9a\u53ef\u4ee5\u89e3\u7801\uff0c\u56e0\u6b64\uff0c\u5c31\u82b1\u534a\u5929\u65f6\u95f4\u7814\u7a76\u4e86\u4e0b\uff0c\u7b97\u662f\u8dd1\u901a\u4e86\u6574\u4e2a\u6d41\u7a0b\uff0c\u53ef\u4ee5\u8bf4\u662f\u5e02\u9762\u4e0a\u6700\u7b80\u6d01\uff0c\u4f9d\u8d56\u6700\u5c11\u7684\u5b9e\u73b0\u4ee3\u7801\u4e86\u3002<\/p>\n<h3>\u4e8c\u3001\u5148\u770b\u9700\u6c42\u548c\u6548\u679c<\/h3>\n<p>\u9700\u8981\u7528\u5230\u89c6\u9891\u89e3\u7801\u7684\u9700\u6c42\u5f88\u591a\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>\u7eafJS\u524d\u7aef\u5b9e\u73b0\u89c6\u9891\u7684\u62fc\u63a5\u6216\u526a\u88c1<\/li>\n<li>\u89c6\u9891\u6dfb\u52a0\u6c34\u5370\u53d8\u6210\u65b0\u89c6\u9891<\/li>\n<li>\u89c6\u9891\u683c\u5f0f\u7684\u6ee4\u955c\u5e94\u7528\u5728webGL\u7279\u6548\u4e0a<\/li>\n<li>\u89c6\u9891\u8f6c\u4e3acanvas\u64ad\u653e\u4ee5\u89c4\u907fAndroid\u4e0bVideo\u5143\u7d20\u9876\u5c42\u95ee\u9898<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\uff0c\u6211\u5c31\u62ff\u7b2c\u4e09\u4e2a\u9700\u6c42\uff0c\u4e5f\u5c31\u662fMP4\u683c\u5f0f\u7684\u6c1b\u56f4\u89c6\u9891\u4f5c\u4e3a\u7279\u6548\u6ee4\u955c\u7684\u9700\u6c42\u4e3e\u4f8b\uff0c\u770b\u770b\u5982\u4f55\u5b9e\u73b0MP4\u89e3\u7801\u6548\u679c\u3002<\/p>\n<p style=\"color: #666;padding:6px 8px;background: #ffffe1;\"><strong>\u6ce8\u610f\uff1a<\/strong>\u5982\u679c\u4ec5\u4ec5\u662f\u53ea\u9700\u8981\u6548\u679c\uff0c\u800c\u4e0d\u9700\u8981\u6700\u7ec8\u7684\u6548\u679c\u518d\u6b21\u5408\u6210\u89c6\u9891\uff0c\u76f4\u63a5\u4f7f\u7528CSS\u6df7\u5408\u6a21\u5f0f\u5c31\u53ef\u4ee5\u4e86\uff0c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/05\/css-mix-blend-mode-screen\/\">\u8fd9\u4e2a4\u5e74\u524d\u5c31\u6709\u4ecb\u7ecd\u8fc7<\/a>\u3002<\/p>\n<h4>\u6548\u679c\u62a2\u5148<\/h4>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202311\/js-mp4-parse-effect-pixi-demo.php\" rel=\"noopener\" target=\"_blank\">MP4\u89c6\u9891\u7d20\u6750\u89e3\u6790\u5e76\u4f5c\u4e3a\u7279\u6548\u6e32\u67d3demo<\/a><\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ea\u7ed8\u5236\u4e86\u80cc\u666f\u56fe\uff0c\u6548\u679c\u4e3a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/201905\/school_overcast-s.jpg\" width=\"150\" height=\"267\" alt=\"\u666f\u7269\u7d20\u6750\u56fe\"><\/p>\n<p>\u7136\u540e\u8fd9\u662f\u4e0b\u96e8\u7279\u6548\u7684\u89c6\u9891\u7d20\u6750\uff1a<\/p>\n<p><video width=\"150\" height=\"267\" autoplay=\"\" preload=\"auto\" loop=\"\" webkit-playsinline=\"true\" playsinline=\"true\" x5-video-player-type=\"h5\" x5-video-orientation=\"portraint\" x5-video-player-fullscreen=\"true\" src=\"\/\/image.zhangxinxu.com\/video\/blog\/201905\/rains-s.mp4\"><\/video><\/p>\n<p>\u5f53\u70b9\u51fb\u56fe\u7247\u4e0b\u65b9\u7684\u6309\u94ae\u540e\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u4e0b\u96e8\u7684\u7279\u6548\u4e86\uff0c\u5982\u4e0b\u622a\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202311\/2023-11-14_235758.png\" width=\"549\" height=\"631\" alt=\"\u622a\u56fe\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6b64\u65f6\u6240\u89c1\u7684\u6548\u679c\u5e76\u4e0d\u662f\u67d0\u4e2avideo\u5143\u7d20\u8986\u76d6\u5728\u56fe\u7247\u4e0a\uff0c\u800c\u662f\u5408\u4e8c\u4e3a\u4e00\u7684canvas\u753b\u5e03\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202311\/2023-11-14_235930.png\" width=\"798\" height=\"369\" alt=\"canvas\u5b9e\u73b0\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e09\u3001\u539f\u7406\u7b80\u8ff0\u548c\u5b9e\u73b0\u4ee3\u7801<\/h3>\n<p>\u6211\u770b\u4e86\u4e0b\uff0c\u65e0\u8bba\u662fwebcodecs\u5b98\u65b9\u9879\u76ee\uff0c\u8fd8\u662f\u79c1\u6709\u7684\u4f7f\u7528Webcodecs API\u7684\u9879\u76ee\uff0c\u51e1\u662f\u9700\u8981\u89e3\u7801MP4\u89c6\u9891\u7684\uff0c\u90fd\u7528\u5230\u4e86\u4e00\u4e2a\u5de5\u5177\uff0cMP4Box.js<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u5c31\u5148\u53bb\u4e86\u89e3\u4e86\u4e0bMP4Box.js\u8fd9\u4e2a\u9879\u76ee\uff0c\u539f\u6765\u8fd9\u4e2aJS\u53ef\u4ee5\u5c06\u4e00\u4e2aMP4\u6587\u4ef6\u5206\u6790\u5f97\u4f53\u65e0\u5b8c\u80a4\uff0c\u4ec0\u4e48\u4fe1\u606f\u90fd\u53ef\u4ee5\u5f04\u5230\uff0c\u81ea\u7136\u4e5f\u5305\u62ec\u65f6\u95f4\u91cc\u9762\u7684\u753b\u9762\u8f68\u9053\u6570\u636e\u548c\u97f3\u8f68\u6570\u636e\u3002<\/p>\n<p>\u5728\u6211\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ea\u9700\u8981\u89c6\u9891\u8f68\u9053\u6570\u636e\uff0c\u6709\u4e86\u6570\u636e\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528Webcodecs API\u4e2d\u7684VideoDecoder\u65b9\u6cd5\u8fdb\u884c\u89e3\u7801\u4e86\u3002<\/p>\n<p>JavaScript\u4ee3\u7801\u5b9e\u73b0\u53c2\u8003\u5982\u4e0b\uff0c\u5168\u7f51\u6700\u7cbe\u7b80\u7248\u672c\u3002<\/p>\n<pre>\/\/ \u4e0b\u9762\u662f\u89c6\u9891\u89e3\u7801\u7684\u5904\u7406\u903b\u8f91\uff0c\u4f7f\u7528mp4box.js\u83b7\u53d6\u89c6\u9891\u4fe1\u606f\r\n\/\/ \u4f7f\u7528 Webcodecs API \u8fdb\u884c\u89e3\u7801\r\nconst mp4url = '.\/rains-s.mp4';\r\nconst mp4box = MP4Box.createFile();\r\n\r\n\/\/ \u8fd9\u4e2a\u662f\u989d\u5916\u7684\u5904\u7406\u65b9\u6cd5\uff0c\u4e0d\u9700\u8981\u5173\u5fc3\u91cc\u9762\u7684\u7ec6\u8282\r\nconst getExtradata = () =&gt; {\r\n    \/\/ \u751f\u6210VideoDecoder.configure\u9700\u8981\u7684description\u4fe1\u606f\r\n    const entry = mp4box.moov.traks[0].mdia.minf.stbl.stsd.entries[0];\r\n\r\n    const box = entry.avcC ?? entry.hvcC ?? entry.vpcC;\r\n    if (box != null) {\r\n        const stream = new DataStream(\r\n            undefined,\r\n            0,\r\n            DataStream.BIG_ENDIAN\r\n        )\r\n        box.write(stream)\r\n         \/\/ slice()\u65b9\u6cd5\u7684\u4f5c\u7528\u662f\u79fb\u9664moov box\u7684header\u4fe1\u606f\r\n        return new Uint8Array(stream.buffer.slice(8))\r\n    }\r\n};\r\n\r\n\/\/ \u89c6\u9891\u8f68\u9053\uff0c\u89e3\u7801\u7528\r\nlet videoTrack = null;\r\nlet videoDecoder = null;\r\n\/\/ \u8fd9\u4e2a\u5c31\u662f\u6700\u7ec8\u89e3\u7801\u51fa\u6765\u7684\u89c6\u9891\u753b\u9762\u5e8f\u5217\u6587\u4ef6\r\nconst videoFrames = [];\r\n\r\nlet nbSampleTotal = 0;\r\nlet countSample = 0;\r\n\r\nmp4box.onReady = function (info) {\r\n    \/\/ \u8bb0\u4f4f\u89c6\u9891\u8f68\u9053\u4fe1\u606f\uff0conSamples\u5339\u914d\u7684\u65f6\u5019\u9700\u8981\r\n    videoTrack = info.videoTracks[0];\r\n\r\n    if (videoTrack != null) {\r\n        mp4box.setExtractionOptions(videoTrack.id, 'video', { \r\n            nbSamples: 100 \r\n        })\r\n    }\r\n\r\n    \/\/ \u89c6\u9891\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\r\n    const videoW = videoTrack.track_width;\r\n    const videoH = videoTrack.track_height;\r\n\r\n    \/\/ \u8bbe\u7f6e\u89c6\u9891\u89e3\u7801\u5668\r\n    videoDecoder = new VideoDecoder({\r\n        output: (videoFrame) =&gt; {\r\n            createImageBitmap(videoFrame).then((img) =&gt; {\r\n                videoFrames.push({\r\n                    img,\r\n                    duration: videoFrame.duration,\r\n                    timestamp: videoFrame.timestamp\r\n                });\r\n                videoFrame.close();\r\n            });\r\n        },\r\n        error: (err) =&gt; {\r\n            console.error('videoDecoder\u9519\u8bef\uff1a', err);\r\n        }\r\n    });\r\n\r\n    nbSampleTotal = videoTrack.nb_samples;\r\n\r\n    videoDecoder.configure({\r\n        codec: videoTrack.codec,\r\n        codedWidth: videoW,\r\n        codedHeight: videoH,\r\n        description: getExtradata()\r\n    });\r\n\r\n    mp4box.start();\r\n};\r\n\r\nmp4box.onSamples = function (trackId, ref, samples) {\r\n    \/\/ samples\u5176\u5b9e\u5c31\u662f\u91c7\u7528\u6570\u636e\u4e86\r\n    if (videoTrack.id === trackId) {\r\n        mp4box.stop();\r\n\r\n        countSample += samples.length;\r\n\r\n        for (const sample of samples) {\r\n            const type = sample.is_sync ? 'key' : 'delta';\r\n\r\n            const chunk = new EncodedVideoChunk({\r\n                type,\r\n                timestamp: sample.cts,\r\n                duration: sample.duration,\r\n                data: sample.data\r\n            });\r\n\r\n            videoDecoder.decode(chunk);\r\n        }\r\n\r\n        if (countSample === nbSampleTotal) {\r\n            videoDecoder.flush();\r\n        }\r\n    }\r\n};\r\n\r\n\/\/ \u83b7\u53d6\u89c6\u9891\u7684arraybuffer\u6570\u636e\r\nfetch(mp4url).then(res =&gt; res.arrayBuffer()).then(buffer =&gt; {\r\n    \/\/ \u56e0\u4e3a\u6587\u4ef6\u8f83\u5c0f\uff0c\u6240\u4ee5\u76f4\u63a5\u4e00\u6b21\u6027\u5199\u5165\r\n    \/\/ \u5982\u679c\u6587\u4ef6\u8f83\u5927\uff0c\u5219\u9700\u8981res.body.getReader()\u521b\u5efareader\u5bf9\u8c61\uff0c\u6bcf\u6b21\u8bfb\u53d6\u4e00\u90e8\u5206\u6570\u636e\r\n    \/\/ reader.read().then(({ done, value })\r\n    buffer.fileStart = 0;\r\n    mp4box.appendBuffer(buffer);\r\n    mp4box.flush();\r\n});<\/pre>\n<p>\u5176\u4e2d\u7684\u5e38\u91cfvideoFrames\u5c31\u662f\u6700\u7ec8\u89e3\u7801\u51fa\u6765\u7684\u89c6\u9891\u7684\u6bcf\u4e00\u5e27\u56fe\u50cf\uff0c\u6709\u4e86\u56fe\u50cf\u5e8f\u5217\uff0c\u4e8b\u60c5\u5c31\u597d\u529e\u4e86\uff0c\u60f3\u5e72\u561b\u5c31\u53ef\u4ee5\u5e72\u561b\u4e86\u3002<\/p>\n<p>\u4f8b\u5982\u8fd9\u91cc\u4f5c\u4e3a\u7279\u6548\u56fe\u7247\u663e\u793a\uff0c\u53ea\u9700\u8981\u8bbe\u7f6e\u7ed8\u5236\u7684\u6df7\u5408\u6a21\u5f0f\u4e3a\u6ee4\u8272screen\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u5177\u4f53\u4ee3\u7801\u4e0d\u5c55\u793a\uff0c\u6709\u5174\u8da3\u53ef\u4ee5\u8bbf\u95ee<a href=\"https:\/\/www.zhangxinxu.com\/study\/202311\/js-mp4-parse-effect-pixi-demo.php\" rel=\"noopener\" target=\"_blank\">demo\u9875\u9762<\/a>\uff0c\u91cc\u9762\u6709\u5b8c\u6574\u4ee3\u7801\u3002<\/p>\n<p>\u4e0d\u8fc7demo\u9875\u9762\u4e2d\u7684\u7ed8\u5236\u4f7f\u7528\u7684\u662fpixijs\u7ed8\u5236\u7684\uff0c\u6709\u4e9b\u4eba\u53ef\u80fd\u4e0d\u719f\u3002<\/p>\n<p>\u4f7f\u7528pixijs\u6f14\u793a\u662f\u4e3a\u4e86\u4e0b\u4e00\u7bc7\u6587\u7ae0\u670d\u52a1\u7684\uff0c\u5982\u679c\u53ea\u662f\u7b80\u5355\u7684\u6df7\u5408\u6a21\u5f0f\u56fe\u50cf\u7ed8\u5236\uff0c\u4f20\u7edf\u76842d canvas\u7ed8\u5236\u5c31\u53ef\u4ee5\u4e86\uff0c\u4f7f\u7528\u53c2\u8003\uff08\u6e90\u7801\u4e2d\u7684draw()\u65b9\u6cd5\u53ef\u4ee5\u6362\u6210\u8fd9\u4e2a\uff09\uff1a<\/p>\n<pre>const draw = () =&gt; {\r\n    const { img, timestamp, duration } = videoFrames[index];\r\n\r\n    \/\/ \u6e05\u9664\u753b\u5e03\r\n    context.clearRect(0, 0, canvas.width, canvas.height);\r\n    \/\/ \u6df7\u5408\u6a21\u5f0f\u8bbe\u4e3a\u6b63\u5e38\r\n    context.globalCompositeOperation = 'source-over';\r\n    \/\/ \u7ed8\u5236\u56fe\u7247\uff0cbgImg\u662f\u80cc\u666f\u56fe\r\n    context.drawImage(bgImg, 0, 0, canvas.width, canvas.height);\r\n    \/\/ \u4f7f\u7528 screen \u6df7\u5408\u6a21\u5f0f\r\n    context.globalCompositeOperation = 'screen';\r\n    context.drawImage(img, 0, 0, canvas.width, canvas.height);\r\n\r\n    \/\/ \u5f00\u59cb\u4e0b\u4e00\u5e27\u7ed8\u5236\r\n    index++;\r\n\r\n    if (index === videoFrames.length) {\r\n        \/\/ \u91cd\u65b0\u5f00\u59cb\r\n        index = 0;\r\n    }\r\n\r\n    setTimeout(draw, duration);\r\n}<\/pre>\n<h3>\u56db\u3001\u79ef\u8dec\u6b65\uff0c\u53c2\u8003\u5b9e\u73b0\u4e0e\u7ed3\u8bed<\/h3>\n<p>\u4f7f\u7528\u4e0a\u5c42\u5de5\u5177\u5b8c\u6210\u4e00\u4e2a\u9700\u6c42\uff0c\u4e5f\u9700\u8981\u6280\u672f\uff0c\u4f46\u8fd9\u4e2a\u6280\u672f\u95e8\u69db\u4e0d\u9ad8\u3002<\/p>\n<p>\u57fa\u4e8e\u539f\u59cb\u7684API\uff0c\u5c3d\u53ef\u80fd\u7528\u6700\u7b80\u6d01\u7684\u5e95\u5c42\u4ee3\u7801\u5b9e\u73b0\uff0c\u8fd9\u4e2a\u624d\u662f\u771f\u6b63\u7684\u5b66\u4e60\u4e0e\u79ef\u7d2f\uff0c\u867d\u7136\u8fc7\u7a0b\u75db\u82e6\uff0c\u4f46\u662f\u5374\u80fd\u548c\u5176\u4ed6\u4eba\u62c9\u5f00\u5dee\u8ddd\uff0c\u63d0\u9ad8\u81ea\u5df1\u7684\u7ade\u4e89\u529b\u3002<\/p>\n<p>\u4e14\u968f\u7740\u76f8\u5173\u7684\u79ef\u7d2f\u8d8a\u6765\u8d8a\u591a\uff0c\u4f60\u4f1a\u9010\u6e10\u6210\u4e3a\u8fd9\u4e2a\u9886\u57df\u7684\u5927\u5496\uff0c\u4e5f\u5c31\u81ea\u7136\u6210\u4e3a\u56e2\u961f\u7684\u4e2d\u6d41\u7825\u67f1\u3002<\/p>\n<p>\u4e00\u5f00\u59cb\u8c01\u90fd\u4e0d\u61c2\u7684\uff0c\u5c31\u50cf\u97f3\u89c6\u9891\u5904\u7406\uff0c\u653e\u5230\u4e03\u516b\u5e74\u524d\uff0c\u53ea\u4f1a\u4f7f\u7528audio\u548cvideo\u5143\u7d20\uff0c\u73b0\u5728\u5462\uff0c\u57fa\u672c\u4e0a\u524d\u7aef\u80fd\u591f\u5b9e\u73b0\u7684\u80fd\u529b\u5728\u8111\u4e2d\u90fd\u6709\u6570\u4e86\uff0c\u518d\u914d\u5408canvas\u3001SVG\u7b49\u5176\u4ed6\u4e0e\u89c6\u89c9\u8868\u73b0\u76f8\u5173\u7684\u79ef\u7d2f\uff0c\u53ef\u4ee5\u505a\u7684\u4e8b\u60c5\u5c31\u591a\u4e86\u3002<\/p>\n<p>\u6210\u957f\u5c31\u662f\u8fd9\u6837\uff0c\u4e00\u6b65\u4e00\u4e2a\u811a\u5370\u6162\u6162\u8d77\u6765\u4e86\uff0c\u5343\u4e07\u4e0d\u8981\u597d\u9ad8\u9a9b\u8fdc\u3002<\/p>\n<p>\u672c\u6587\u7684MP4\u89e3\u7801\u5e76\u6ca1\u6709\u97f3\u9891\u90e8\u5206\uff0c\u5982\u679c\u4f60\u6709\u8fd9\u65b9\u9762\u7684\u9700\u6c42\uff0c\u4e0b\u9762\u4e24\u4e2a\u8d44\u6e90\u4f60\u53ef\u4ee5\u53c2\u8003\u4e0b\uff1a<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/gpac\/mp4box.js\/issues\/243#issuecomment-950450478\" rel=\"noopener\" target=\"_blank\">mp4box\u9879\u76ee\u4e2d\u548cwebcodecs\u6709\u4e2a\u7684\u4e00\u4e2aissues\u56de\u7b54<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/hughfenghen\/WebAV\/blob\/main\/packages\/av-cliper\/src\/mp4-utils.ts\" rel=\"noopener\" target=\"_blank\">WebAV\u9879\u76ee\u4e2dmp4-utils.ts<\/a><\/li>\n<\/ul>\n<p>OK\uff0c\u5c31\u8fd9\u4e48\u591a\uff0c\u53c8\u662f\u4e00\u7bc7\u5176\u4ed6\u5730\u65b9\u96be\u89c5\u7684\u4f18\u8d28\u6587\u7ae0\uff0c\u611f\u8c22\u9605\u8bfb\uff0c\u6b22\u8fce<button onclick=\"shareWeixin.click()\" class=\"entry-share-btn\">\u5206\u4eab<\/button>\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6bd4\u8f83\u5bb3\u7f9e\uff0c\u4e0d\u613f\u610f\u5206\u4eab\uff0c\u4e5f\u53ef\u4ee5\u8d2d\u4e70\u6211\u5199\u7684\u4e66\u7c4d\uff0c\u6216\u8005<a href=\"https:\/\/juejin.cn\/book\/7184663814950879270\" rel=\"noopener\" target=\"_blank\"><mark>\u5c0f\u518c<\/mark><\/a>\u4ee5\u8868\u652f\u6301\uff0c\u563f\u563f~<\/p>\n<p>? ? ? ? ?<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=11043\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=11043<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202311\/bear-lake.jpg\" width=\"160\" height=\"103\" alt=\"\u5c01\u9762\u56fe \u98ce\u666f \u718a\uff0c\u6811\u6728\uff0c\u9ad8\u5c71\uff0c\u6e56\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u5e94\u8be5\u662f\u56fd\u5185\u7b2c\u4e00\u7bc7\u4e13\u95e8\u4ecb\u7ecd\u7528mp4box.js\u548cVideoDecoder\u65b9\u6cd5\u89e3\u7801MP4\u89c6\u9891\u5e8f\u5217\u5e27\u7684\u6587\u7ae0\u4e86\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[180],"tags":[53,994,1948,1193,1920,1917,1749],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/11043"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=11043"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/11043\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=11043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=11043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=11043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}