javascript - 从视频反应中拍摄快照
问题描述
视频反应
捕获帧
我正在尝试使用捕获帧从视频反应中获取快照,但是当我调用函数 captureFrame(video) 时,它会触发下一个。
错误:未捕获的 DOMException:无法在“HTMLCanvasElement”上执行“toDataURL”:可能无法导出受污染的画布。
我的代码如下:
captureSnapshot = () => {
const video = this.player_video.video.video;
video.setAttribute('crossOrigin', 'anonymous');
console.log(video);
const buf = captureFrame(video);
const image = document.createElement('img');
image.setAttribute('crossOrigin', 'anonymous');
image.setAttribute('src', window.URL.createObjectURL(new window.Blob([buf])));
console.log('captured frame src', image);
this.setState({ image: image.src });
}
解决方案
基本上是解决了错误,包括video-react播放器道具中的crossOrigin ,如下所示:
<Player
ref={player => { this.player_video = player }}
crossOrigin={'anonymous'}
/>
推荐阅读
- python - 我正在尝试使用 SQLAlchemy 作为 db.session 在烧瓶应用程序中表示 sql 连接
- ansible - 字典项目的 Ansible 条件
- c# - 如何保存来自 C# 代码的用户响应并防止多选单选按钮
- android - Android:如何使用 BottomAppBar 为 FAB 创建垂直动画?
- jenkins - Jenkins DSL 作业:GroovyCastException 无法转换对象
- html - 如何为另一个元素内的元素添加css样式颜色
- excel - 根据值将数据值移植到另一个工作表
- laravel - Laravel WorkflowSubscriber 类,根据当前转换调用不正确的方法有条件地调用保护方法
- ios - 如何在表格视图中添加 Firebase 值
- mysql - 来自别名未知列的 MySQL 总和