var video = documentgetElementById("videoElement"); //获取前台要截图的video对象
videosetAttribute('crossOrigin', 'anonymous') // 跨域处理
var canvas = windowcanvas = documentcreateElement("canvas");
canvaswidth = 500;
canvasheight = 300;
canvasgetContext('2d')drawImage(video, 0, 0,500,500); // 将当前视频渲染在画布上,大小和视频分辨率一致
var images = canvastoDataURL("image/png"); //canvas的api中的toDataURL()保存图像[toDataUrl](https://developercdnmozillanet/zh-CN/docs/Web/API/HTMLCanvasElement/toDataURL)
var arr = imagessplit(','),
mime = arr[0]match(/:();/)[1],
bstr = atob(arr[1]),
n = bstrlength,
u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstrcharCodeAt(n);
}
var file = new File([u8arr], 'cutoutjpg', { type: mime });
let config = {headers: { 'Content-Type': 'multipart/form-data' }}
let formData = new FormData();
formDataappend('multipart', file, filename);
axiospost('http://127001:8080/api/v1/workorder/operation/upload', formData, config)
then(res => {})
以上就是关于video视频,实现截图功能,获得base64图转file并上传全部的内容,包括:video视频,实现截图功能,获得base64图转file并上传、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)