# 合成服务

# 所需文件

文件描述 文件名 文件位置
服务jar包 compileserver.jar /opt/compile
jar 包配置文件 application.properties /opt/compile
合成可执行程序 processServer /opt/program
合成的配置文件 processServer.conf /opt/program
合成的人脸模型 ms_face_v1.0.2.model /opt/program

# 操作系统

Ubuntu 18.04

# 配置环境

  1. 更新linux安装程序源,安装 jre
apt update
apt upgrade
apt install default-jre
  1. 安装QT和ffmpeg相关库
apt-get install qt5-default
apt install libavutil55
apt install libavcodec57
apt install libavformat57
apt install libswresample2
apt install libswscale4
apt install libqt5multimedia5
apt install libqt5multimedia5-plugins
  1. 安装 xserver 并启动
apt-get install ubuntu-desktop
apt-get install xinit
nohup startx &

# jar 包配置文件

application.properties,需要放在jar包同目录下,或者同目录的config文件夹下,并不是所有的字段都需要,都有默认值,只需要把需要修改的放进来即可。

#端口号
server.port=8090

#本地compiler路径
compilerPath=/opt/program/processServer
#人脸模型路径
compilerCmd-faceModelFilePath=/opt/program/ms_face_v1.0.2.model
#本地临时路径
projectPath=/tmp/editor/project/

#默认存储云
#qcloud(腾讯云), qiniu(七牛), aws(亚马逊), aliyun(阿里云), #baidu(百度云),local(本地)
#ksyun(金山云)
defaultStorageType=

#存储云accessKey
accessKey=
#存储云secretKey
secretKey=

#七牛相关配置
QiniuBucket=bsedit
QiniuHost=http://bsedit.meishesdk.com
#腾讯云相关配置
QcloudRegion=ap-beijing
QcloudBucket=bsedit-1257467088
QcloudOriginHost=https://bsedit-1257467088.cos.ap-beijing.myqcloud.com
QcloudHost=https://easset.meishesdk.com
#aws相关配置
AwsS3Region=us-west-1
AwsS3Bucket=bsedit
AwsS3OriginHost=https://bsedit.s3-us-west-1.amazonaws.com
AwsS3Host=https://d3eban5zvz6846.cloudfront.net
#阿里云相关配置
AliyunEndpoint=http://oss-cn-beijing.aliyuncs.com
AliyunBucket=bseditor
AliyunOriginHost=https://bseditor.oss-cn-beijing.aliyuncs.com
AliyunHost=https://alieasset.meishesdk.com
AliyunAuthKey=
AliyunSignatureUrlEnabled=false
#百度云相关配置
BOSEndpoint=http://bj.bcebos.com
BOSBucket=testbsedit
BOSOriginHost=https://testbsedit.bj.bcebos.com
BOSHost=https://testbsedit.bj.bcebos.com
#金山云相关配置
KsyunEndpoint   =
KsyunBucket     =
KsyunOriginHost =
KsyunHost       =
#挂载盘相关配置
LocalFilePath = /opt/file/bsedit
LocalFileHost = https://testeditor.meishesdk.com:15050/bsedit

#存储路径是否按照时间划分  根路径/年/月/日/模块路径
dateSplitPath = true

#公用的存储前缀
commonPrefix = editor

#云存储桶下保存合成的视频的路径
videoKey=video-compiled/

#鉴权地址
compilerCmd-licServerURL=https://...../app

#特效包下载的目录,需要和processServer的配置保持一致
assets.download.dir.path = /opt/material/

#不使用创建任务时的uuid作为上传文件的uuid,而是新生成一个
upload.with.new.uuid.enabled = false

#任务调度器的地址,用于和任务调度器保持心跳
task.scheduler.url = http://localhost:9999
#发送心跳的时间间隔,毫秒
heartbeat.fixed.delay = 10000
#服务可同时运行的最大数量
max.execute.count = 3
#能访问到当前服务的url,用于注册到任务调度器
server.url = http://localhost:${server.port}

#是否发送metadata的请求,原来complete和metadata是两个请求,后来精简到complete
send.metadata.enabled = false

#合成器合成需要的线程数量
compiler.thread.count = 4

#进程距离上次的活跃时间,单位是秒
processExpireTime = 600

#连接超时 单位毫秒
connectTimeout = 5000
#从连接池中获取可用连接超时 单位毫秒
connectionRequestTimeout = 5000
#读取超时 单位毫秒
socketTimeout= 5000
#失败后重试次数
httpRequestRetryCount = 3
#失败后睡眠时间 单位毫秒
httpRequestFailSleepTime = 3000 

# processServer 的配置文件

processServer.conf 需要保证必须和可执行程序在同一个目录下,用户没有特殊要求,只需要部署assetsFolder 即可。

{
	"videoBitrate": 10000000,
	"audioBitrate": 320000,
	"fps":25,
	"crf":17,
	"gopSize":15,
	"sampleRate":48000,
  "maxRes":"8K",
	"assetsFolder":"/opt/material/"
}

# 启动服务

切换到jar包的目录下

  1. 查看xserver是否启动
ps -ef| grep xserver
  1. 设置display 环境变量
export DISPLAY=$(ps -ef | grep 'xserver' | grep -v grep |awk '{print $12}')
  1. 启动 java 服务
nohup java -jar compileserver.jar >/dev/null 2>&1 &

# 日志说明

会产生2个日志目录,都会在 /opt/compile 目录下。分别是 logs 和 log。 logs 是Java程序产生的日志,每天一个日志文件,只保留最近30天的日志。 log 是processServer 的产生的日志,每个任务产生一个日志文件。