Rat's

云转码切片express-ffmpeg+CMS一体化系统安装教程
说明:云转码系统估计很多人知道,博主体验过七彩云、FFMpeg WebUI等云转码,感觉都不是很适合自己,而且好像...
扫描右侧二维码阅读全文
12
2018/09

云转码切片express-ffmpeg+CMS一体化系统安装教程

说明:云转码系统估计很多人知道,博主体验过七彩云、FFMpeg WebUI等云转码,感觉都不是很适合自己,而且好像都不更新了,特别是FFMpeg WebUI,貌似很久前就一直停留在0.9.6版本,恰好最近看到了个基于nodejs制作的开源免费的云转码切片系统,功能上基本可以满足个人日常需求了,而且博主感觉nodejs的转码切片速度比现有的很多php转码程序都快些,这里就分享下,给有需求的人用。

项目介绍

该云转码不再是简单的云转码系统,而是CMS系统+云转码系统一体化,自带整个完备的并且对移动端友好的,而且非常利于SEO优化的自适应CMS系统,根据后台的分类系统和门户CMS管理系统,直接在首页达成完备的在线视频播放系统,适用于在线教育、企业内部培训视频、在线视频自媒体门户等多种运用方向。

如果你不想使用CMS,也可以单独当它是一个可以在线视频转码的工具,对视频进行在线格式转换,很适合用来做一个视频转码的网站。

  • 实现大文件分块上传,批量上传。
  • 实现服务器端自动动态码率转码并且切片,完成后会自动删除原视频文件。
  • 实现批量添加水印和字幕,和同时处理。
  • 实现截图,默认自动生成四张截图。
  • 一键获取分享链接,设置防盗链,token防盗链或者仅允许指定域名iframe调用。
  • ts切片文件域名分发,负载均衡,支持无限多服务器同步分发。

开源版官网:https://ffmpeg.moejj.com/
开源版演示:https://www.moejj.com

收费加强版

目前开源版已停止更新,如果需要更强的功能,比如去水印/跑马灯,加跑马灯等众多功能,可直接选择更强的纯净版和高级版程序,完全不一样的界面和体验,超优的售后,任何系统问题均可以协助或帮你解决。

官方网站:https://www.moemv.com/
高级版官网:https://www.efvcms.com/

截图

请输入图片描述
请输入图片描述
请输入图片描述
请输入图片描述
请输入图片描述
请输入图片描述

更新

【2019.1.17】
更新部分安装步骤,使出错率更小。

为什么要使用云转码

传统视频如果没有正确的压缩,一般来说尺寸非常大,动则3Gb4Gb的大小,再者因为视频需要在网站中进行播放,传统中如果放置常规的flv或者mp4格式,那么浏览器会一直进行缓存,并且在缓存在一定播放长度之后才会进行播放,这样会消耗更多的带宽和让用户等待更长的时间,所以转码之后再进行切片是非常必须的,一来无损的压缩视频文件使其占用磁盘尺寸更小,并且基于hls格式,也是M3u8格式中储存了所有ts切片列表,这种模式加载,只需要加载第一个ts切片视频就可以开始播放,这样就使用户等待的时间更少,减少服务器带宽使用,并且画质的损失很小。这也就是为什么现在大部分视频网站都是使用hls格式来播放的。

具体功能

  • 后台云转码加切片,运用最精简的代码,做成最快的转码+切片功能。
  • 秒切功能,切片速度领先所有市面收费云转码系统。
  • 视频分类、视频筛选、视频搜索,后台一应俱全。
  • 防盗链、token防盗链,多重防盗链,避免流量损失,可以设置指定域名只能iframe调用。
  • 字幕烧录,水印烧录,超级简单的操作,即可将字幕烧录进视频或者添加水印到视频中。
  • 支持vtt字幕,后台可以根据不同的视频上传不同的vtt字幕,前台播放自动加载字幕。
  • 视频截图,后台配置截图数,云转码切片的时候自动截图。
  • ts分发,多服务器同步内容,ts文件自动循环加域名前缀,负载均衡。
  • cms系统配置,站点名称设置、seo标题设置、seokeywords设置,seodescription设置,前台显示截图设置,前台自动生成cms系统,自适应布局,针对移动端优化,seo效果极佳。

新增功能

#增加会员系统
增加会员系统,可以不开启CMS,独立开启会员系统,双向验证,安全可靠,后台可以配合卡劵生成,前台用户使用卡劵进行升级。

#真正意义上的权限系统
路由层面的权限系统,非网上的播放器假权限,根据权限不同,相同的M3U8播放文件返回不同的内容,比如普通会员只能播放3分钟,就只会返回3分钟的切片内容,升级之后才会返回完整的切片内容。

#卡劵系统
后台设定卡劵生成,可以设置开通会员时间,用户前台使用即可升级到对应的会员,到期之后权限失效,需要重新开通,如果连续使用则是累加会员时间。

安装

如果你觉得安装很困难,想很快安装好,可以使用博主写的Docker镜像,安装教程:点击访问

安装教程官网其实有,不过仅有Ubuntu的手动教程,其它系统都没有,博主发现该程序所需的大部分环境宝塔面板均可以直接安装,鉴于为小白着想,这里就用宝塔面板安装该程序,支持的系统也多。

所需环境:nodejsexpressjsmongoDbffmpegRedis

1、安装宝塔

#Centos系统
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh
#Ubuntu系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
#Debian系统
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && bash install.sh

安装完成后,进入面板,点击左侧软件管理,然后安装MongoDbRedisNginx(使用域名访问才需要安装,反之不用)。注意Debian安装MongoDb之前还需要使用命令apt install sudo,不然可能存在MongoDb启动不了的情况。

2、安装ffmpeg

wget https://www.moerats.com/usr/down/ffmpeg/ffmpeg-git-$(getconf LONG_BIT)bit-static.tar.xz
tar xvf ffmpeg-git-*-static.tar.xz
mv ffmpeg-git-*/ffmpeg  ffmpeg-git-*/ffprobe /usr/bin/
rm -rf ffmpeg-git-*

3、安装Nodejs

#Debian/Ubuntu系统
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt install -y nodejs git

#Centos系统
curl -sL https://rpm.nodesource.com/setup_8.x | bash -
yum install nodejs git -y

安装PM2express

npm install -g pm2 express

4、创建数据库
创建之前建议去面板软件管理那里找到MongoDb数据库重启一下。

#这里数据库名,用户和密码都是ffmpeg
mongo
use ffmpeg
db.createUser({user:"ffmpeg",pwd:"ffmpeg",roles:[{role:"readWrite",db:"ffmpeg"}]})
db.auth("ffmpeg","ffmpeg")

如果显示1则增加用户正确,再使用Ctrl+D退出。这里如果有No such file or directory报错,请检查下数据库运行状态。

5、配置云转码

git clone https://gitee.com/quazero/express-ffmpeg.git
cd express-ffmpeg
#创建config文件夹
mkdir config
cd config

创建并编辑auth.js配置文件:

nano auth.js

将以下代码复制进去:

#该配置比很早的版本多了三个设置项,很多人出错就在这里,secret是session需要的秘钥,login是后台登陆地址,loginmsg 是后台未登录显示的内容,默认是404。
module.exports = {
    user: "admin",
    password: "admin",
    db: "ffmpeg",
    dbuser: "ffmpeg",
    dbpassword: "ffmpeg",
    secret: "yoursecret",
    login: "/adminlogin",
    loginmsg: "404 Not Found"
};

再使用Ctrl+XY确认退出编辑模式,参数从上往下依次是登陆云转码平台的账号,密码,数据库,数据库用户名,数据库密码。本教程安装的mongodb数据库为ffmpeg,用户名和密码都是ffmpeg,可以自行进行修改。

6、安装并运行云转码

cd /root/express-ffmpeg
npm install
#如果服务器重启,则必须在express-ffmpeg源码文件里重新运行命令启动
pm2 start bin/www -i 0

7、反向代理
点击左侧网站,添加站点,然后再点击添加好了的域名名称,这时候就进入了站点配置,点击反向代理,目标URL填入http://127.0.0.1:3000,再启用反向代理即可。

8、站点配置
最后打开xx.com/adminlogin,输入设定的账号密码,本教程设置的是adminadmin,进入之后点击设置,转码设置需要绑定域名,截图数需大于0,然后域名分发可以不设置,但需要提交下、CMS设置也需要绑定域名,播放器设置需要关闭强制QQ浏览器播放,当然其它设置需要自行修改,不然视频很可能因为某个设置的问题放不了。

最后这里要说下的就是,如果你使用后,心理有个疑问,为什么转码速度这么慢,或者很慢?那么就意味着你需要换一个强一点的CPU独立服务器,切勿用VPSVPSCPU限制很多,如果你拿来转码,很有可能你的VPS会被暂停,CPU选择可参考跑分榜→传送门

当然你要是只用秒切功能的话,对CPU要求就不是那么大了,不是很耗资源。

最后如果你只是玩玩,那建议使用开源版,如果正式使用,或者想要功能多,那建议选择纯净版或者高级版。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。
最后修改:2021 年 02 月 25 日 08 : 09 PM

发表评论 取消回复

311 条评论

  1. 爱看动漫的小梁

    CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
    CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
    In file included from ../src/CanvasPattern.cc:9:0:
    ../src/Image.h:19:21: 致命错误:gif_lib.h:没有那个文件或目录
    #include <gif_lib.h>

    ^

    编译中断。
    make: * [Release/obj.target/canvas/src/CanvasPattern.o] 错误 1
    make: 离开目录“/www/wwwroot/express-ffmpeg/node_modules/canvas/build”
    gyp ERR! build error
    gyp ERR! stack Error: make failed with exit code: 2
    gyp ERR! stack at ChildProcess.onExit (/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
    gyp ERR! stack at emitTwo (events.js:126:13)
    gyp ERR! stack at ChildProcess.emit (events.js:214:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
    gyp ERR! System Linux 3.10.0-862.el7.x86_64
    gyp ERR! command "/www/server/nvm/versions/node/v8.12.0/bin/node" "/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /www/wwwroot/express-ffmpeg/node_modules/canvas
    gyp ERR! node -v v8.12.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok

    sharp@0.20.8 install /www/wwwroot/express-ffmpeg/node_modules/sharp
    (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

    info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-linux-x64.tar.gz
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.3.12 (node_modules/canvas):
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.3.12 install: node-gyp rebuild
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

    added 385 packages from 408 contributors and audited 796 packages in 1127.664s
    found 4 vulnerabilities (3 low, 1 high)
    run npm audit fix to fix them, or npm audit for details

    这次是centos 7 64位

    1. Rat's
      @爱看动漫的小梁

      我刚测试的无任何问题,教程的一些细节我也加了点,你还是检查下你的操作吧。

      1. 爱看动漫的小梁
        @Rat's

        请问,你的CentOS 7是什么版本!

        1. Rat's
          @爱看动漫的小梁

          CentOS 7系统。

          1. 爱看动漫的小梁
            @Rat's

            请问,宝塔安装那四个环境,极速安装还是编译安装?

            1. Rat's
              @爱看动漫的小梁

              先极速,有问题就编译。

    2. Rat's
      @爱看动漫的小梁

      我晚上试试看吧。

  2. 爱看动漫的小梁

    安装报错啊
    root@ubuntu:/www/wwwroot/express-ffmpeg# npm install
    npm WARN deprecated crypto@1.0.1: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
    npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
    npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
    npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
    npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

    canvas@1.3.12 install /www/wwwroot/express-ffmpeg/node_modules/canvas
    node-gyp rebuild

    Package cairo was not found in the pkg-config search path.
    Perhaps you should add the directory containing `cairo.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'cairo' found
    gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
    gyp ERR! configure error
    gyp ERR! stack Error: gyp failed with exit code: 1
    gyp ERR! stack at ChildProcess.onCpExit (/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
    gyp ERR! stack at emitTwo (events.js:126:13)
    gyp ERR! stack at ChildProcess.emit (events.js:214:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
    gyp ERR! System Linux 4.15.0-29-generic
    gyp ERR! command "/www/server/nvm/versions/node/v8.12.0/bin/node" "/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /www/wwwroot/express-ffmpeg/node_modules/canvas
    gyp ERR! node -v v8.12.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok

    sharp@0.20.8 install /www/wwwroot/express-ffmpeg/node_modules/sharp
    (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

    info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-linux-x64.tar.gz
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.3.12 (node_modules/canvas):
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.3.12 install: node-gyp rebuild
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

    added 385 packages from 408 contributors in 123.028s
    root@ubuntu:/www/wwwroot/express-ffmpeg#

    是gyp开头的报错

    1. Rat's
      @爱看动漫的小梁

      有点像gcc问题,安装下开发者工具包看看,yum -y groupinstall "Development Tools",再有问题建议百度一下。

      1. 爱看动漫的小梁
        @Rat's

        我用的还是Ubuntu 64位系统,这个命令真的合适吗

        1. Rat's
          @爱看动漫的小梁

          忘了,我以为你会按照我的建议用CentOS 7。

  3. 爱看动漫的小梁

    版本貌似都更新了,这个教程还有效吗?我安装还是有几处提示错误的gyp ERR!

    1. Rat's
      @爱看动漫的小梁

      看了下源码,这个安装教程没啥问题,你可以去研究下官方文档https://ffmpeg.moejj.com/guide/install.html。

  4. 爱看动漫的小梁

    最新安装出新
    gyp ERR! stack at emitTwo (events.js:87:13)
    gyp ERR! stack at ChildProcess.emit (events.js:172:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    gyp ERR! System Linux 4.15.0-29-generic
    gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"
    gyp ERR! cwd /www/wwwroot/express-ffmpeg/node_modules/canvas
    gyp ERR! node -v v4.2.6
    gyp ERR! node-gyp -v v3.0.3
    gyp ERR! not ok
    npm WARN install:canvas@1.3.12 canvas@1.3.12 install: node-gyp rebuild
    npm WARN install:canvas@1.3.12 Exit status 1

    sharp@0.20.8 install /www/wwwroot/express-ffmpeg/node_modules/sharp
    (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

    sh: node: 未找到命令
    /bin/sh: node: 未找到命令
    gyp: Call to 'node -e "console.log(require('./lib/libvips').pkgConfigPath())"' returned exit status 127 while in binding.gyp. while trying to load binding.gyp
    gyp ERR! configure error
    gyp ERR! stack Error: gyp failed with exit code: 1
    gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:354:16)
    gyp ERR! stack at emitTwo (events.js:87:13)
    gyp ERR! stack at ChildProcess.emit (events.js:172:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
    gyp ERR! System Linux 4.15.0-29-generic
    gyp ERR! command "/usr/bin/nodejs" "/usr/bin/node-gyp" "rebuild"
    gyp ERR! cwd /www/wwwroot/express-ffmpeg/node_modules/sharp
    gyp ERR! node -v v4.2.6
    gyp ERR! node-gyp -v v3.0.3
    gyp ERR! not ok
    npm ERR! Linux 4.15.0-29-generic
    npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
    npm ERR! node v4.2.6
    npm ERR! npm v3.5.2
    npm ERR! code ELIFECYCLE

    npm ERR! sharp@0.20.8 install: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the sharp@0.20.8 install script '(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)'.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the sharp package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR! npm bugs sharp
    npm ERR! Or if that isn't available, you can get their info via:
    npm ERR! npm owner ls sharp
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR! /www/wwwroot/express-ffmpeg/npm-debug.log
    Ubuntu 64位系统

    1. Rat's
      @爱看动漫的小梁

      提示node命令未找到,你可以去面板管理那里卸载pm2,再重新安装,建议你使用CentOS系统。

  5. gscsds

    大佬,后台登录提示此页面不能正确地重定向

    1. Rat's
      @gscsds

      是打不开么?检查下域名设置什么的看看。

      1. gscsds
        @Rat's

        不是,是在admin/下输入正确的账号密码后就会无限重定向,直接ip访问也是这样

        1. Rat's
          @gscsds

          这个问题还没遇到过,你清空缓存看看?

          1. gscsds
            @Rat's

            清空过,火狐的隐私模式,和换浏览器都一样

            1. Rat's
              @gscsds

              这个就不是很清楚了。

              1. gscsds
                @Rat's

                后台登录页不能是admin,会无限跳转,终于知道了

                1. Rat's
                  @gscsds

                  是的,我也发现了,所以我下午改了下教程。

  6. 咔嚓

    请问这个错误实怎么回事啊
    Package cairo was not found in the pkg-config search path.
    Perhaps you should add the directory containing `cairo.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'cairo' found
    gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
    gyp ERR! configure error
    gyp ERR! stack Error: gyp failed with exit code: 1
    gyp ERR! stack at ChildProcess.onCpExit (/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
    gyp ERR! stack at emitTwo (events.js:126:13)
    gyp ERR! stack at ChildProcess.emit (events.js:214:7)
    gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
    gyp ERR! System Linux 4.4.0-28-generic
    gyp ERR! command "/www/server/nvm/versions/node/v8.12.0/bin/node" "/www/server/nvm/versions/node/v8.12.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
    gyp ERR! cwd /root/express-ffmpeg/node_modules/canvas
    gyp ERR! node -v v8.12.0
    gyp ERR! node-gyp -v v3.8.0
    gyp ERR! not ok

    1. Rat's
      @咔嚓

      什么系统?CentOS的话可以yum install cairo cairo-devel -y,Debian可以试试apt-get install libcairo2-dev libjpeg-dev libgif-dev -y

  7. 海天

    博主 有没有文档、pdf和这个视频功能一整套的系统推荐啊

    1. Rat's
      @海天

      暂时没发现。

  8. 寒惜

    第三步那里 执行了npm install express -gd
    出现
    -bash: npm: command not found
    想问下博主这个怎么解决?百度谷歌了一圈还是没解决。。

    1. Rat's
      @寒惜

      面板安装PM2管理器后需要重新进入ssh才行。

  9. 墨池

    创建并编辑auth.js配置文件:
    ssh输入这个nano auth.js提示
    -bash: nano: command not found
    怎么办

    1. Rat's
      @墨池

      善用搜索,缺少nano命令,yum install nano -y。

  10. 墨池

    大佬 能出个视频教程就好了!