• <bdo id='akdaO'></bdo><ul id='akdaO'></ul>

    <i id='akdaO'><tr id='akdaO'><dt id='akdaO'><q id='akdaO'><span id='akdaO'><b id='akdaO'><form id='akdaO'><ins id='akdaO'></ins><ul id='akdaO'></ul><sub id='akdaO'></sub></form><legend id='akdaO'></legend><bdo id='akdaO'><pre id='akdaO'><center id='akdaO'></center></pre></bdo></b><th id='akdaO'></th></span></q></dt></tr></i><div id='akdaO'><tfoot id='akdaO'></tfoot><dl id='akdaO'><fieldset id='akdaO'></fieldset></dl></div>
    <tfoot id='akdaO'></tfoot>

      1. <legend id='akdaO'><style id='akdaO'><dir id='akdaO'><q id='akdaO'></q></dir></style></legend>

        <small id='akdaO'></small><noframes id='akdaO'>

        在画布上绘制 HTML5 视频 - Google Chrome 崩溃,Aw Snap

        Draw HTML5 Video onto Canvas - Google Chrome Crash, Aw Snap(在画布上绘制 HTML5 视频 - Google Chrome 崩溃,Aw Snap)
        <tfoot id='E02YS'></tfoot>

          <small id='E02YS'></small><noframes id='E02YS'>

          • <i id='E02YS'><tr id='E02YS'><dt id='E02YS'><q id='E02YS'><span id='E02YS'><b id='E02YS'><form id='E02YS'><ins id='E02YS'></ins><ul id='E02YS'></ul><sub id='E02YS'></sub></form><legend id='E02YS'></legend><bdo id='E02YS'><pre id='E02YS'><center id='E02YS'></center></pre></bdo></b><th id='E02YS'></th></span></q></dt></tr></i><div id='E02YS'><tfoot id='E02YS'></tfoot><dl id='E02YS'><fieldset id='E02YS'></fieldset></dl></div>
            <legend id='E02YS'><style id='E02YS'><dir id='E02YS'><q id='E02YS'></q></dir></style></legend>
              <bdo id='E02YS'></bdo><ul id='E02YS'></ul>

                  <tbody id='E02YS'></tbody>

                  本文介绍了在画布上绘制 HTML5 视频 - Google Chrome 崩溃,Aw Snap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我用mp4文件源画了一个视频HTML5,为了改进 css 样式和所有内容,我像许多 Javascript 开发人员一样,每隔 20 毫秒将视频的帧图像重绘到画布上,

                  I drew a video HTML5 with mp4 file source, To improve css styling and everything, I redraw the frame image of the video onto canvas in 20ms interval just like many Javascript developer does,

                  关于 w3schools 的示例:最后的绘图示例

                  Example on w3schools: The Last Drawing Example

                  如果你在 IE10 或 firefox 上显示它会显示一切正常,但是当我在 Chrome 上显示它时(我的是最新版本 31),一段时间后它会崩溃(aw snap!)

                  If you display it on IE10 or firefox it will display everything fine, But when I display it on Chrome (mine is the latest version 31), after some times it will crash (aw snap!)

                  知道为什么或有什么解决办法吗?

                  Any idea why or is there any solution to this?

                  推荐答案

                  改用 requestAnimationFrame (rAF).20ms 没有意义.大多数视频在美国以 30 FPS(NTSC 系统)运行,在欧洲以 25 FPS(PAL 系统)运行.那将分别是 33.3 毫秒和 40 毫秒.

                  Use requestAnimationFrame (rAF) instead. The 20ms makes no sense. Most video runs at 30 FPS in the US (NTSC system) and at 25 FPS in Europe (PAL system). That would be 33.3ms and 40ms respectively.

                  话虽如此,rAF 将尝试以 60 FPS(或显示器刷新率高达 60 Hz)运行,因此我们可以通过使用切换开关降低此处的帧速率.

                  That being said, rAF will attemp to run at 60 FPS (or the monitor refresh rate up to 60 Hz) so we can reduce the frame rate here by using a toggle switch.

                  在任何情况下,rAF 都会使绘图同步到监视器,因此在任何情况下,在这些情况下,它都会比 setInterval/setTimeout 更好.

                  In any case rAF will enable the drawing to be synced to the monitor so in any case it will be a better choice than setInterval/setTimeout in cases such as these.

                  您遇到崩溃的原因可能是由于发生了堆叠(但也可能与系统有关).

                  The reason you get a crash is probably due to stacking taking place (but it could also be system related).

                  var toggle = true;
                  
                  function loop() {
                  
                      toggle = !toggle;
                      if (toggle) {
                          if (!v.paused) requestAnimationFrame(loop);
                          return;
                      }
                  
                      /// draw video frame every 1/30 frame
                      ctx.drawImage(v, 0, 0);
                  
                      /// loop if video is playing
                      if (!v.paused) requestAnimationFrame(loop);
                  }
                  

                  然后使用该示例的简化版本:

                  Then use this simplified version of that example:

                  var v = document.getElementById("video1");
                  var c = document.getElementById("myCanvas");
                  var ctx = c.getContext('2d');
                  
                  v.addEventListener('play', loop ,false);
                  

                  这篇关于在画布上绘制 HTML5 视频 - Google Chrome 崩溃,Aw Snap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  What is quot;X-Content-Type-Options=nosniffquot;?(什么是“X-Content-Type-Options=nosniff?)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                      <bdo id='RUb6U'></bdo><ul id='RUb6U'></ul>

                      <small id='RUb6U'></small><noframes id='RUb6U'>

                      <i id='RUb6U'><tr id='RUb6U'><dt id='RUb6U'><q id='RUb6U'><span id='RUb6U'><b id='RUb6U'><form id='RUb6U'><ins id='RUb6U'></ins><ul id='RUb6U'></ul><sub id='RUb6U'></sub></form><legend id='RUb6U'></legend><bdo id='RUb6U'><pre id='RUb6U'><center id='RUb6U'></center></pre></bdo></b><th id='RUb6U'></th></span></q></dt></tr></i><div id='RUb6U'><tfoot id='RUb6U'></tfoot><dl id='RUb6U'><fieldset id='RUb6U'></fieldset></dl></div>

                        <tbody id='RUb6U'></tbody>

                      <tfoot id='RUb6U'></tfoot>
                          <legend id='RUb6U'><style id='RUb6U'><dir id='RUb6U'><q id='RUb6U'></q></dir></style></legend>