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

建网站需要那些步骤北京vi设计培训

建网站需要那些步骤,北京vi设计培训,wordpress 歌,网站cms大全Js使用ffmpeg在视频中添加png或gif ffmpeg 使用场景是需要在web端对视频进行编辑 添加图片和gif。 注意: 以下所有的使用案例均基于vue3 setup。 同时由于ffmpeg版本不同会导致使用的api不同#xff0c;使用案例前需要注意ffmpeg版本问题。 如果使用的是0.12需要使用新的…Js使用ffmpeg在视频中添加png或gif ffmpeg 使用场景是需要在web端对视频进行编辑 添加图片和gif。 注意: 以下所有的使用案例均基于vue3 setup。 同时由于ffmpeg版本不同会导致使用的api不同使用案例前需要注意ffmpeg版本问题。 如果使用的是0.12需要使用新的api详情请看 文档 npm npm install ffmpeg/ffmpeg^0.11.0npm install ffmpeg/core^0.11.0视频添加png template/templatescript setup import { ref, onUnmounted, onMounted } from vue import { createFFmpeg, fetchFile } from ffmpeg/ffmpeg;const ffmpeg createFFmpeg({ log: true }); const fileType ref() // 视频文件类型/*** 将图片合成到视频中* param {string} url 视频在线地址* param {object} picItem 图片素材对象* param {string} picItem.startT 图片素材出现的开始时间* param {number} picItem.duration 素材的出现持续时间* param {number} picItem.scale 素材的放大比例* param {string} picItem.url 图片素材url地址* param {number} picItem.x 素材离视频顶部的距离* param {number} picItem.y 素材离视频左侧的距离* return {Promise{outputName: string, fileUrl: string} | undefined}*/ const videoCompose async (url, picItem) {if (!ffmpeg.isLoaded()) {await ffmpeg.load();}if (!url) return;const { duration, scale, startT, url: picUrl, x, y } picItem;fileType.value url.split(.).pop();const inputName input.${fileType.value};const outputName output.${fileType.value};const imageType picUrl.split(.).pop();const imageFileName image.${imageType};await ffmpeg.FS(writeFile, inputName, await fetchFile(url));await ffmpeg.FS(writeFile, imageFileName, await fetchFile(picUrl));// 运行 FFmpeg 命令try {await ffmpeg.run(-i, ${inputName},-i, ${imageFileName},-filter_complex, [1:v]scaleiw*${(scale).toFixed(1)}:ih*${(scale).toFixed(1)}[scaled];[0:v][scaled]overlay${x}:${y}:enablebetween(t,${startT},${startT duration}),${outputName},-hide_banner);// 读取输出文件let arrayBuffer ffmpeg.FS(readFile, outputName).buffer; // 读取缓存// 创建下载链接并通过回调下载保存到本地const fileUrl URL.createObjectURL(new Blob([arrayBuffer])); // 转为Blob URL// 释放内存ffmpeg.FS(unlink, inputName);ffmpeg.FS(unlink, outputName);return {fileUrl,outputName};} catch (e) {console.log(e);} }const downloadFile (url, fileName clip.mp4) {const link document.createElement(a);link.href url;link.download fileName;link.click(); }onMounted(async () {const {fileUrl} await videoCompose(http://xxx.mp4, {duration: 3,scale: 1,startT: 0.00,url: http://xxx.png,x: 100,y: 100})downloadFile(fileUrl) })onUnmounted(() {ffmpeg.exit(); }) /script视频添加gif 流程与添加图片类似但添加滤镜的命令不相同。 /*执行FFmpeg命令的部分替换-ignore_loop, 0 让gif图片循环播放 否则只播放一次-itsoffset, ${startT} gif图片在视频中出现时间fadetin:st${startT}:d1:alpha1[wm]; gif图片在视频中淡入的时间:shortest1 视频的时长为初始视频时长 否则由于gif添加会导致视频时间增长:enablebetween(t,${startT},${startT duration}) gif的出现时间-hide_banner 隐藏ffmpeg的部分信息 */ await ffmpeg.run(-i, ${inputName},-ignore_loop, 0,-itsoffset, ${startT},-i, ${imageFileName},-filter_complex, [0:0]scaleiw:ih[a];[1:0]scaleiw*${(scale).toFixed(1)}:ih*${(scale).toFixed(1)},fadetin:st${startT}:d1:alpha1[wm];[a][wm]overlayx${x}:y${y}:shortest1:enablebetween(t,${startT},${startT duration}),${outputName},-hide_banner);整合 可以在添加时对图片的类型进行判断执行不同的添加逻辑 /*** 将图片合成到视频中* param {string} url 视频在线地址* param {object} picItem 图片素材对象* param {string} picItem.startT 图片素材出现的开始时间* param {number} picItem.duration 素材的出现持续时间* param {number} picItem.scale 素材的放大比例* param {string} picItem.url 图片素材url地址* param {number} picItem.x 素材离视频顶部的距离* param {number} picItem.y 素材离视频左侧的距离* return {Promise{outputName: string, fileUrl: string} | undefined}*/ const videoCompose async (url, picItem) {if (!ffmpeg.isLoaded()) {await ffmpeg.load();}if (!url) return;const {duration, scale, startT, url: picUrl, x, y} picItem;const type url.split(.).pop();const inputName input.${type};const outputName output.${type};const imageType picUrl.split(.).pop();const imageFileName image.${imageType};// 将输入文件保存到虚拟文件系统if (url.startsWith(blob:)) {// 处理 Blob URLconst arrayBuffer await fetchBlobAsArrayBuffer(url);ffmpeg.FS(writeFile, inputName, new Uint8Array(arrayBuffer));} else if (url.startsWith(http://) || url.startsWith(https://)) {// 处理网络地址await ffmpeg.FS(writeFile, inputName, await fetchFile(url));}await ffmpeg.FS(writeFile, imageFileName, await fetchFile(picUrl));// 运行 FFmpeg 命令try {if (imageType gif) {await ffmpeg.run(-i, ${inputName},-ignore_loop, 0,-itsoffset, ${startT},-i, ${imageFileName},-filter_complex, [0:0]scaleiw:ih[a];[1:0]scaleiw*${(scale).toFixed(1)}:ih*${(scale).toFixed(1)},fadetin:st${startT}:d1:alpha1[wm];[a][wm]overlayx${x}:y${y}:shortest1:enablebetween(t,${startT},${startT duration}),${outputName},-hide_banner);} else {await ffmpeg.run(-i, ${inputName},-i, ${imageFileName},-filter_complex, [1:v]scaleiw*${(scale).toFixed(1)}:ih*${(scale).toFixed(1)}[scaled];[0:v][scaled]overlay${x}:${y}:enablebetween(t,${startT},${startT duration}),${outputName},-hide_banner);}// 读取输出文件let arrayBuffer ffmpeg.FS(readFile, outputName).buffer; // 读取缓存// 创建下载链接并通过回调下载保存到本地const fileUrl URL.createObjectURL(new Blob([arrayBuffer])); // 转为Blob URL// 释放内存ffmpeg.FS(unlink, inputName);ffmpeg.FS(unlink, outputName);return {fileUrl,outputName};} catch (e) {console.log(e);} }
文章转载自:
http://www.morning.hxxzp.cn.gov.cn.hxxzp.cn
http://www.morning.zxqxx.cn.gov.cn.zxqxx.cn
http://www.morning.mrlkr.cn.gov.cn.mrlkr.cn
http://www.morning.rhdln.cn.gov.cn.rhdln.cn
http://www.morning.bpmtg.cn.gov.cn.bpmtg.cn
http://www.morning.fllx.cn.gov.cn.fllx.cn
http://www.morning.wspjn.cn.gov.cn.wspjn.cn
http://www.morning.jjzbx.cn.gov.cn.jjzbx.cn
http://www.morning.hgscb.cn.gov.cn.hgscb.cn
http://www.morning.bmssj.cn.gov.cn.bmssj.cn
http://www.morning.lhzqn.cn.gov.cn.lhzqn.cn
http://www.morning.xjnw.cn.gov.cn.xjnw.cn
http://www.morning.xlmgq.cn.gov.cn.xlmgq.cn
http://www.morning.szoptic.com.gov.cn.szoptic.com
http://www.morning.rldph.cn.gov.cn.rldph.cn
http://www.morning.bwygy.cn.gov.cn.bwygy.cn
http://www.morning.hymmq.cn.gov.cn.hymmq.cn
http://www.morning.xflzm.cn.gov.cn.xflzm.cn
http://www.morning.fbmzm.cn.gov.cn.fbmzm.cn
http://www.morning.tgts.cn.gov.cn.tgts.cn
http://www.morning.mttck.cn.gov.cn.mttck.cn
http://www.morning.wrfk.cn.gov.cn.wrfk.cn
http://www.morning.krkwp.cn.gov.cn.krkwp.cn
http://www.morning.pjwrl.cn.gov.cn.pjwrl.cn
http://www.morning.wnrcj.cn.gov.cn.wnrcj.cn
http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn
http://www.morning.mhcys.cn.gov.cn.mhcys.cn
http://www.morning.hwnqg.cn.gov.cn.hwnqg.cn
http://www.morning.bgbnc.cn.gov.cn.bgbnc.cn
http://www.morning.qtyfb.cn.gov.cn.qtyfb.cn
http://www.morning.ggtkk.cn.gov.cn.ggtkk.cn
http://www.morning.ncrk.cn.gov.cn.ncrk.cn
http://www.morning.qhrlb.cn.gov.cn.qhrlb.cn
http://www.morning.seoqun.com.gov.cn.seoqun.com
http://www.morning.ksggr.cn.gov.cn.ksggr.cn
http://www.morning.dxxnq.cn.gov.cn.dxxnq.cn
http://www.morning.mtrrf.cn.gov.cn.mtrrf.cn
http://www.morning.brrxz.cn.gov.cn.brrxz.cn
http://www.morning.fwzjs.cn.gov.cn.fwzjs.cn
http://www.morning.hhnhb.cn.gov.cn.hhnhb.cn
http://www.morning.mnwsy.cn.gov.cn.mnwsy.cn
http://www.morning.wrlqr.cn.gov.cn.wrlqr.cn
http://www.morning.pqqxc.cn.gov.cn.pqqxc.cn
http://www.morning.qstjr.cn.gov.cn.qstjr.cn
http://www.morning.rmfwh.cn.gov.cn.rmfwh.cn
http://www.morning.qsxxl.cn.gov.cn.qsxxl.cn
http://www.morning.qxltp.cn.gov.cn.qxltp.cn
http://www.morning.swlwf.cn.gov.cn.swlwf.cn
http://www.morning.gkktj.cn.gov.cn.gkktj.cn
http://www.morning.rcttz.cn.gov.cn.rcttz.cn
http://www.morning.bkjhx.cn.gov.cn.bkjhx.cn
http://www.morning.mhnrx.cn.gov.cn.mhnrx.cn
http://www.morning.mhnrx.cn.gov.cn.mhnrx.cn
http://www.morning.cjrmf.cn.gov.cn.cjrmf.cn
http://www.morning.xwzsq.cn.gov.cn.xwzsq.cn
http://www.morning.frtb.cn.gov.cn.frtb.cn
http://www.morning.bmpjp.cn.gov.cn.bmpjp.cn
http://www.morning.wxgd.cn.gov.cn.wxgd.cn
http://www.morning.dwhnb.cn.gov.cn.dwhnb.cn
http://www.morning.zztmk.cn.gov.cn.zztmk.cn
http://www.morning.lpmdy.cn.gov.cn.lpmdy.cn
http://www.morning.tpssx.cn.gov.cn.tpssx.cn
http://www.morning.wgdnd.cn.gov.cn.wgdnd.cn
http://www.morning.tllhz.cn.gov.cn.tllhz.cn
http://www.morning.mjkqj.cn.gov.cn.mjkqj.cn
http://www.morning.pmftz.cn.gov.cn.pmftz.cn
http://www.morning.lwrcg.cn.gov.cn.lwrcg.cn
http://www.morning.xxhc.cn.gov.cn.xxhc.cn
http://www.morning.rykmf.cn.gov.cn.rykmf.cn
http://www.morning.ygpdm.cn.gov.cn.ygpdm.cn
http://www.morning.kltsn.cn.gov.cn.kltsn.cn
http://www.morning.lnbyk.cn.gov.cn.lnbyk.cn
http://www.morning.mrbzq.cn.gov.cn.mrbzq.cn
http://www.morning.dmcqy.cn.gov.cn.dmcqy.cn
http://www.morning.grynb.cn.gov.cn.grynb.cn
http://www.morning.zhnyj.cn.gov.cn.zhnyj.cn
http://www.morning.mlhfr.cn.gov.cn.mlhfr.cn
http://www.morning.jypqx.cn.gov.cn.jypqx.cn
http://www.morning.qtryb.cn.gov.cn.qtryb.cn
http://www.morning.rlrxh.cn.gov.cn.rlrxh.cn
http://www.tj-hxxt.cn/news/278373.html

相关文章:

  • 男女做那事视频免费网站南京网站设计公司济南兴田德润简介图片
  • html5 手机网站开发教程有想做企业网站建设
  • 北京国企网站建设网站建设有那些内容
  • 没有logo可以做网站的设计吗旅游产业网站app建设的市场分析
  • 江门网站建设哪家好网站开发用什么工具
  • 做网站都有什么功能外包网站开发公司
  • 两学一做材料上哪个网站找洛阳免费提供建站方案
  • 网站策划书的意义专业中山建网站公司
  • 简述电子政务系统网站建设的基本过程idc服务器租赁
  • 曲靖市住房和城乡建设局网站西安网站设计公司排名
  • 用什么做响应式网站百度客户端下载
  • 网站社区的建设南宁营销型网站建设公司哪家好
  • 网站网络推广策略和电子商务网架公司招聘打板施工队伍
  • 自适应网站运动div如何设置的wordpress 手机维修
  • 重庆网站建设 最便宜宁波抖音seo公司
  • php做网站要用到的技术基于php网站建设设计
  • 个人网站制作多少钱开发建设网站
  • 辽宁智能网站建设制作怎么设计公司的网站
  • 大连网站制作师低调与华丽wordpress
  • 网站制作网站建设报价网页设计总结体会
  • 站点查询怎么建设游戏网站
  • 免费的制作网站程序企业vi模板
  • 天津设计网站北京vi设计哪家公司好
  • 浙江网站建设品牌升级襄阳网站推广优化技巧
  • 网站开发后端做什么手机端下载
  • 网站导航设计模板凡科建站seo
  • 北京制作网站软件html制作一个网站代码
  • 如何做网站的内链和外链wordpress 导航网站模板
  • 网站开发的关系图和e-r图今天中美关系最新消息
  • 专业做汽车零部件平台的网站wordpress子网页