Ad

Is It Possible To Use Canvas To Play A Video,but Through Animating The Pixels?

- 1 answer

So the thing is that ,I want to play a video on a website that does not allow me to play any videos or show any photo's.

Therefore i come across an idea to allow the client side script to download one picture from the server, so that we can avoid tainting the canvas.

After that ,the server will extract pixel data from the first frame of the video,and then send that data to the client side script to be processed and replace the default pixel data that is already on the canvas with the one that has been received.

Then for efficiency ,the server will compare the first frame with the second, and then if for example the first frame consists of a pixel with the same color and position as the second frame then the server will only send the pixels that need to be changed,so this means that the server will only send the pixel data that is needed.

This process will be automatic until the end of a video.

so my full question is that ,is this possible ,and if 'yes' ,tell me if that will slow down the user's device or not, and if it will , is there a way to improve efficiency?

Ad

Answer

That might be possible indeed, and an interesting theoretical subject on video frame manipulation.

But in practice, it has a taste of re-inventing the wheel. The following behaviour is a basic on many video compression format :

the server [or the file format] will only send the pixels that need to be changed

In order to be efficient, that can be combined with a motion vector showing how the constant part has moved from the previous frame, in a Predicted frame.

And yes, it will most probably slow down the user interface, as it would never get the efficiency of a real video stream specifically designed for this purpose.

Ad
source: stackoverflow.com
Ad