简体   繁体   English

HTML5捕获暂停视频流的图像并保存

[英]HTML5 Capture image of paused video stream and save it

I have a html5 webpage and on there I want to provide a stream. 我有一个html5网页,在那里我想提供一个流。 This works so far with the following HTML code: 到目前为止,这使用以下HTML代码:

<video id="v" autoplay="autoplay">
    <source src="http://localhost:8080/stream.ogg" type="video/ogg">
</video>

But now I want to provide the option that the user can pause the video and save the current seen picture as jpeg file on the server. 但现在我想提供一个选项,用户可以暂停视频并将当前看到的图片保存为服务器上的jpeg文件。

But now I don't know how to get the image and save it a preferred location on the server. 但现在我不知道如何获取图像并将其保存在服务器上的首选位置。 How can I save the current shown image as jpeg? 如何将当前显示的图像保存为jpeg?

 function capture() { var canvas = document.getElementById("c"); var video = document.getElementById("v"); if (video.paused) { canvas.getContext('2d').drawImage(video, 0, 0); } } 
 <video id="v" autoplay="autoplay" > <source src="http://html5doctor.com/demos/video-canvas-magic/video.webm" type="video/ogg"> </video> <input type="button" value="Capture" onclick="capture()"/> <canvas id="c" width="500" height="500"></canvas> 

With the help from: http://html5doctor.com/video-canvas-magic/ 在以下帮助下: http//html5doctor.com/video-canvas-magic/

To get the image on the canvas to an image file, you can use canvas.toDataUrl or canvas.toDataUrlHD (experimental). 要将画布上的图像提供给图像文件,可以使用canvas.toDataUrlcanvas.toDataUrlHD (实验)。 See the API here: https://developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement 请在此处查看API: https//developer.mozilla.org/en/docs/Web/API/HTMLCanvasElement

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM