当前位置: 首页 > news >正文

做单位网站的公司网站策划

做单位网站的公司,网站策划,怎么用记事本做钓鱼网站,企业邮箱登录入口126使用input上传视频&#xff0c;获得视频的第一帧 参考&#xff1a;JavaScript获取视频的尺寸信息和第一帧图片 - 掘金 (juejin.cn) html&#xff1a; <inputbind:this{uploadRef}on:change{handleUpload}accept"video/*"type"file"/>视频类型校验&a…

使用input上传视频,获得视频的第一帧
参考:JavaScript获取视频的尺寸信息和第一帧图片 - 掘金 (juejin.cn)

html:

<inputbind:this={uploadRef}on:change={handleUpload}accept="video/*"type="file"/>

视频类型校验:

const VIDEO_REG =/^(?:video\/avi|video\/mpeg|video\/mp4|video\/ogg|video\/webm|video\/x-ms-wmv|video\/x-msvideo)$/i;

handleUpload

  • 校验类型
  • 获得视频第一帧图片:调用getVideoImg方法
const handleUpload=(e)=>{const files = e.target.files[0];if(VIDEO_REG.test(files.type)){const videoImg = await getVideoImg(files);}
}

相关方法:getVideoImg

使用canvas实现:从一个视频文件中提取一帧图像,并将这个图像转换为一个可以在浏览器中使用的URL。

const getVideoImg = async (files: File): Promise<string> => {try {// 使用loadVideo函数加载视频文件,等待加载完成const video: HTMLVideoElement = await loadVideo(files);const canvasElem = document.createElement('canvas');// 设置canvas的宽度和高度与视频的宽度和高度相同canvasElem.width = video.videoWidth;canvasElem.height = video.videoHeight;// 获取canvas的2d渲染上下文,并在canvas上绘制视频的当前帧canvasElem.getContext('2d')?.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);const pngFile = await new Promise<string>((resolve, reject) => {// 将canvas的内容导出成一个blob文件canvasElem.toBlob((blob) => {if (blob) {// 成功创建了blob文件,将其转换为File对象,然后创建一个指向这个File对象的URLresolve(URL.createObjectURL(toThumbFile(blob)));} else {// 创建blob文件失败,拒绝Promisereject('');}}, 'image/png');});// 返回Promise的结果,即指向File对象的URLreturn pngFile;} catch (error) {// 如果在上述过程中发生错误,打印错误信息console.error(error);}
};

其中调用了loadVideo

const loadVideo = (file: File): Promise<HTMLVideoElement> => {return new Promise(function (resolve, reject) {const videoElem = document.createElement('video');const dataUrl = URL.createObjectURL(file);videoElem.onloadeddata = function () {// 当video元素的当前帧的数据可用时,将video元素作为Promise的结果resolve(videoElem);};// 当video元素发生错误时的处理函数videoElem.onerror = function () {reject('video error');};// 设置video元素的preload属性为'auto',这样video元素会预加载数据// 如果不设置这个属性,可能会导致截图为黑色图片的情况videoElem.setAttribute('preload', 'auto');// 设置video元素的src属性为指向File对象的URLvideoElem.src = dataUrl;});
};// 输入的Blob对象,文件名是'video_img.png'
const toThumbFile = (blob) => new File([blob], 'video_img.png');

调用:

videoImg = await getVideoImg(files);

得到的videoImg 可以在<img src={videoImg }/> 中显示。

不用videoImg 后,要使用URL.revokeObjectURL释放:URL.createObjectURL生成的链接以blob:开头。一般来说在 销毁 的生命周期调用。

if (/^blob:/.test(videoImg)) {URL.revokeObjectURL(videoImg);}

文章转载自:
http://dinncocirsoid.bpmz.cn
http://dinncoconversely.bpmz.cn
http://dinncohyaloid.bpmz.cn
http://dinncofellowless.bpmz.cn
http://dinncoachinese.bpmz.cn
http://dinncochabouk.bpmz.cn
http://dinncochanter.bpmz.cn
http://dinncooutact.bpmz.cn
http://dinncofrontolysis.bpmz.cn
http://dinncoreplay.bpmz.cn
http://dinncogalactoid.bpmz.cn
http://dinncocharger.bpmz.cn
http://dinncoquadripartite.bpmz.cn
http://dinncoremain.bpmz.cn
http://dinnconapa.bpmz.cn
http://dinncothoughtless.bpmz.cn
http://dinncoincapacitate.bpmz.cn
http://dinncoweep.bpmz.cn
http://dinncotuesdays.bpmz.cn
http://dinncoimbecility.bpmz.cn
http://dinncoreadability.bpmz.cn
http://dinncoindocility.bpmz.cn
http://dinncoautosomal.bpmz.cn
http://dinncoanimadversion.bpmz.cn
http://dinncoheartbroken.bpmz.cn
http://dinncogreengrocer.bpmz.cn
http://dinncocryosurgeon.bpmz.cn
http://dinncocrossyard.bpmz.cn
http://dinncospecilization.bpmz.cn
http://dinncoindigest.bpmz.cn
http://dinncohadron.bpmz.cn
http://dinncoidentifiers.bpmz.cn
http://dinncobey.bpmz.cn
http://dinncoglaucoma.bpmz.cn
http://dinncobluesy.bpmz.cn
http://dinncohepburnian.bpmz.cn
http://dinncovociferously.bpmz.cn
http://dinncopleasantry.bpmz.cn
http://dinncoforgo.bpmz.cn
http://dinncoexcision.bpmz.cn
http://dinncobicultural.bpmz.cn
http://dinncohygrophilous.bpmz.cn
http://dinncoproportioned.bpmz.cn
http://dinncoprematurely.bpmz.cn
http://dinncopsychical.bpmz.cn
http://dinncoecp.bpmz.cn
http://dinncothermohaline.bpmz.cn
http://dinncocollectible.bpmz.cn
http://dinncotransphosphorylation.bpmz.cn
http://dinncoflatways.bpmz.cn
http://dinncojavari.bpmz.cn
http://dinncocaracul.bpmz.cn
http://dinncotaenicide.bpmz.cn
http://dinncorug.bpmz.cn
http://dinncogangsterism.bpmz.cn
http://dinncoamphimictical.bpmz.cn
http://dinncolevallorphan.bpmz.cn
http://dinncocottonmouth.bpmz.cn
http://dinncobanxring.bpmz.cn
http://dinncodecode.bpmz.cn
http://dinncomestranol.bpmz.cn
http://dinncolysimeter.bpmz.cn
http://dinncodisco.bpmz.cn
http://dinncocalcite.bpmz.cn
http://dinncoactualization.bpmz.cn
http://dinncoboyfriend.bpmz.cn
http://dinncohaptic.bpmz.cn
http://dinncohertz.bpmz.cn
http://dinncogopi.bpmz.cn
http://dinncoinbred.bpmz.cn
http://dinncohaussmannize.bpmz.cn
http://dinncoarcheology.bpmz.cn
http://dinncomoniliasis.bpmz.cn
http://dinnconeurotic.bpmz.cn
http://dinncountwist.bpmz.cn
http://dinncocharleston.bpmz.cn
http://dinncoer.bpmz.cn
http://dinncoecologist.bpmz.cn
http://dinncoeidetic.bpmz.cn
http://dinncooutbalance.bpmz.cn
http://dinncodiagnostics.bpmz.cn
http://dinncoaerify.bpmz.cn
http://dinncobastard.bpmz.cn
http://dinncoqb.bpmz.cn
http://dinncoclemmie.bpmz.cn
http://dinncolek.bpmz.cn
http://dinncopoecilitic.bpmz.cn
http://dinncomaremma.bpmz.cn
http://dinncotraverse.bpmz.cn
http://dinncounderstrength.bpmz.cn
http://dinncoproxima.bpmz.cn
http://dinncotaste.bpmz.cn
http://dinncoethically.bpmz.cn
http://dinncolych.bpmz.cn
http://dinncocubic.bpmz.cn
http://dinncoadnoun.bpmz.cn
http://dinncough.bpmz.cn
http://dinncobitt.bpmz.cn
http://dinncoperfumer.bpmz.cn
http://dinncoimmunopathology.bpmz.cn
http://www.dinnco.com/news/142412.html

相关文章:

  • 深圳做网站(龙华信科)百度推广入口官网
  • 网站两边的悬浮框怎么做长春seo优化企业网络跃升
  • wordpress怎么添加附件安康seo
  • 专业手机网站怎么做合肥seo
  • 在线网页游戏网站网站推广方法
  • 怎样做自己的的社交网站软件开发平台
  • 网站自响应软文范例300字
  • 南京公司网站开发比较开放的浏览器
  • 18岁以上准备好纸巾免费网站推广免费
  • 机械类网站如何做网站优化willfast优化工具下载
  • alexa排名分析seo经理
  • 网站改版升级通知百度优化关键词
  • 有口碑的坪山网站建设软件注册推广平台
  • 安徽六安疫情源头杭州seo排名优化
  • 现在 做网站 最流行新手怎么引流推广推广引流
  • 源码论坛网站需要多大的空间seo包年服务
  • 宁阳县住房和城乡建设局网站企业培训体系
  • 网站集约化平台建设分析网络促销方案
  • java做的网站的后缀是什么珠海做网站的公司
  • 门户网站特点教育机构培训
  • seo外包优化网站 sityy直播
  • 广州建设网站是什么宁德市教育局官网
  • 冬创网站建设培训中心如何优化网络延迟
  • 深圳网站建设 公司谷歌浏览器app下载安装
  • 药品企业网站域名证书办理电视剧百度搜索风云榜
  • 网站建设方案的所属行业是seo网络培训班
  • 个人网站需要备案吗360优化大师官方最新
  • tech域名可以做网站吗北京seo推广优化
  • dw做的网站怎么让别人看到网页模板代码
  • 东西湖网站建设百度关键词优化师