用js实现抖音字说的动画效果
字说在抖音中非常的火,把名人的经典语录拉出来,背景配上名人,然后通过自己铿锵有力的声音表现出来,非常有感染力,一般要实现抖音的这种视频效果,需要下载app,付费成为vip会员后才能使用,身为开发人员,我们肯定是自己动手丰衣足食,那么今天我们来看看怎么使用js在网页中实现这种抖音字说的效果,
好了,今天主要用到typemoneky.js这款插件,定义好每个文字段的顺序及字体颜色旋转模式,然后就行了,背景音乐自己加一个
完整的代码如下
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>BFW NEW PAGE</title> <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" /> <script id="bfwone" data="dep=jquery.17&err=0" type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/bfwone.js"></script> <script type="text/javascript"> bready(function() { use(["typemoneky-min", "typemoneky-min"], function() { var e = new TypeMoneky({ debug: !1, box: demo, list: [{ type: "text", value: "所有的" }, { type: "rotate", value: "lb" }, { type: "text", value: "创业者", color: "white" }, { type: "rotate", value: "lb" }, { type: "text", value: "应该多花点时间" }, { type: "text", value: "去学习", color: "#fe131a" }, { type: "text", value: "别人" }, { type: "text", value: "是怎么失败的", color: "red" }], lineHeight: 1.17, beforeCreate: function(e, t, a) { e()}}); e.init(); var t = setInterval(function() { return e.isEnd?void clearInterval(t): void e.start()}, 1e3); }); }); </script> <style> body { font-size: 16px; background: #aaa; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } #demo { position: absolute; left: 0; top: 0; width: 414px; height: 736px; right: 0; margin: auto; max-width: 100%; max-height: 100%; } .tm-inner { background: url('http://repo.bfw.wiki/bfwrepo/image/5e145322b59bf.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_414,h_736,/quality,q_90') !important; } .isMob #demo { width: 100%; height: 100%; } </style> </head> <body class="page-simple"> <audio autoplay="true" src="http://repo.bfw.wiki/bfwrepo/sound/5e148aa3821f2.mp3" ></audio> <div id="app"> <main class="main"> <div id="demo"> </div> </main> </div> </body> </html>那么字说完了,怎么发布到抖音里呢,直接下一个录屏软件screentogif,下载地址:http://down.bfw.wiki/file/15666323849202900020.html
录完后,导出mp4格式就好了
注意如果没装ffmpeg,先安装一下,ffmpeg下载地址:http://ffmpeg.org/
还可以使用格式工厂,直接搜索下载安装后,可以录视频保存为mp4格式
网友评论0