Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

javascript - 是否可以使用画布来播放视频,但是可以通过动画设置像素?(Is it possible to use canvas to play a video,but through animating the pixels?)

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?(所以我的全部问题是,这是否可能,如果是,请告诉我是否会减慢用户设备的速度,如果可以,是否可以提高效率?)

  ask by Christopher translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.(是的,它很可能会减慢用户界面的速度,因为它将永远无法获得专门为此目的设计的真实视频流的效率。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...