Inverting video colors

The purpose of this recipe is to demonstrate how to perform pixel manipulations on videos in much the same way as we did with images. In this recipe, we'll invert the colors of a short video clip.

drawImage() methodIpixel manipulationworkingnverting video colors

Note

WARNING: This recipe must be run on a web server due to security constraints with the getImageData() method.

Follow these steps to invert the colors of a video:

How to do it...

  1. Create a cross-browser method that requests an animation frame:
    window.requestAnimFrame = (function(callback){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || ...

Get HTML5 Canvas Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.