# 直播剪服务部署
- 修改ubuntu时间, 更新linux安装程序源
timedatectl set-timezone Asia/Shanghai
apt update
apt upgrade
- 安装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
- 安装FFMPEG
1. 上传ffmpeg压缩包到服务器
把ftp上的ffmpeg.zip(目录:/wjf/ffmpeg.zip)上传到/opt目录下
unzip ffmpeg.zip
2. 安装依赖
sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texinfo zlib1g-dev
3.汇编库
Yasm是一个完全重写的NASM(The Netwide Assembler)汇编;NASM是一个为可移植性与模块化而设计的一个80x86的汇编器。它支持相当多的目标文件格式,包括Linux,*BSD,a.out,ELF,COFF,Mach−O,Microsoft 16−bit OBJ,Win32以及Win64,同时也支持简单的二进制文件生成。它的语法被设计的简单易懂,相较Intel的语法更为简单,支持目前已知的所有x86架构之上的扩展语法,同时也拥有对宏命令的良好支持。
sudo apt-get install yasm
sudo apt-get install nasm
4.视频库
要支持X264等视频处理,就需要安装相应的库:
sudo apt-get install libx264-dev
sudo apt-get install libx265-dev
5.音频库
要支持常见的音频处理,需要安装:
sudo apt-get install libfdk-aac-dev
sudo apt-get install libmp3lame-dev
sudo apt-get install libopus-dev
sudo apt install libssl-dev libssl-doc
6.更新openssl版本(此步骤通常用于openssl版本不是1.1.1的情况下)
执行openssl -version 为1.1.1,如果是1.1.0则需要手动下载openssl进行编译安装
https://www.cnblogs.com/jsjliyang/p/10606908.html
7.配置ffmpeg并安装
cd /opt/ffmpeg/ffmpeg-4.3.2
./configure --prefix=/opt/ffmpeg --enable-libx264 --disable-yasm --enable-nonfree --enable-libfdk-aac --enable-shared --enable-gpl --enable-libmp3lame --enable-libopus --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-openssl
make
make install
8.库配置和路径配置
配置库所在路径,以便FFmpeg能加载相应库。打开配置文件
sudo vi /etc/ld.so.conf
在文件末尾加上:
/opt/ffmpeg/lib
然后执行sudo ldconfig,重新加载配置以生效。
9.路径配置
为能随时使用FFmpeg,需要把对应目录添加到路径中。
vi ~/.bashrc
在文件末尾加上:
FFMPEG_HOME=/opt/ffmpeg
PATH=$FFMPEG_HOME/bin:$PATH
执行 source ~/.bashrc
- 安装mysql
apt-get update
apt-get install mysql-server
#初始化配置(参考下面的选项)
mysql_secure_installation
#1
VALIDATE PASSWORD PLUGIN can be used to test passwords...
Press y|Y for Yes, any other key for No: N (我的选项)
#2
Please set the password for root here...
New password: (输入密码)
Re-enter new password: (重复输入)
#3
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them...
Remove anonymous users? (Press y|Y for Yes, any other key for No) : N (我的选项)
#4
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network...
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y (我的选项)
#5
By default, MySQL comes with a database named 'test' that
anyone can access...
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : N (我的选项)
#6
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y (我的选项)
#设置mysql登陆时候需要密码
> use mysql;
> update user set authentication_string=password("你的密码") where user='root'; #(无password字段的版本,也就是版本<=5.7的)
> update user set password=password('你的密码') where user='root'; #(有password字段的版本,版本>5.7的)
> update user set plugin="mysql_native_password";
> flush privileges;
> exit;
#检查mysql服务状态
systemctl status mysql.service
#创建云剪和直播剪数据库
drop database if EXISTS livebsedit;
create database livebsedit CHARACTER SET utf8 COLLATE utf8_general_ci;
1.直播剪包livebsedit,配置文件config.yaml,转码器三个文件放到/opt/livebsedit目录下
cd /opt/livebsedit
chmod 755 NvTranscoder
chmod 755 livebsedit
nohup ./livebsedit &
查看日志tail -f latest_log
输出以下两行则表明服务启动成功
router register success
websocket manage start
2.config.yaml字段说明
#system conf
system:
addr: 8888
useSSL: false
sslPemFilePath:
sslKeyFilePath:
clientType: ""
#task conf
taskConf:
transcodeConf:
#转码器路径
transcoderPath: /opt/localpath/NvTranscoder
#转码器错误缩率图url(为空则不设置错误缩率图)
errThumbnailUrl: ""
#执行转码任务超时时间(到达超时时间后自动杀死任务,单位:s,默认180s)
execTranscodeTimeOut:
#待转缩率图任务队列长度(默认1000,通常不需要修改)
transThumbnailChan:
#转缩率图的转码任务最大执行数量(默认10)
transThumbnailMax:
#转缩率图查询不到任务休眠时间(单位:s,默认30s)
transThumbnailNoJobSleepTime:
#定时查询正在转码m3u8是否有新增缩率图间隔时间(单位:s,默认5s)
checkNewThumbnailsInterval:
compileConf:
#合成器路径
compilerPath:
#使用哪种合成方式:FFMPEG-使用ffmpeg命令合成,PROCESS-使用合成器合成 (默认FFMPEG)
compileMode: "FFMPEG"
#合成完是否需要转码
needTranscode: true
#liveConfig conf
liveConf:
#直播收录持续时长(正整数则生效,否则无效,单位:s,默认24h)
recruitDuration: 0
#是否启用重定向url(比如阿里云的流需要重定向的地址才会更新m3u8里的内容)
enableRedirectOriginUrl: false
#单次扫描转缩率图的转码任务最大数量(默认10)
scanM3u8TransThumbnailMax: 5
#m3u8定时任务扫描间隔(单位s,默认5s)
m3u8TaskInterval:
#扫描长时间无更新m3u8中间隔(默认60s)
scanNoupdateM3u8Interval:
#是否启用语音识别功能(默认false)
enableSpeechRecognition:
#websocket conf
websocketConf:
#是否启用websocket心跳机制
enableHeartbeat: false
#清除直播收录任务的超时时间(单位:s),需要和enableHeartBeat配合使用
timeout: 90
#zap logger configuration
zap:
#可使用 "debug", "info", "warn", "error", "dpanic", "panic", "fatal",
level: 'info'
#console: 控制台, json: json格式输出
format: 'console'
prefix: '[NV]'
director: 'log'
linkName: 'latest_log'
showLine: true
#LowercaseLevelEncoder:小写, LowercaseColorLevelEncoder:小写带颜色,CapitalLevelEncoder: 大写, CapitalColorLevelEncoder: 大写带颜色,
encodeLevel: 'LowercaseColorLevelEncoder'
stacktraceKey: 'stacktrace'
logInConsole: true
#mysql connect configuration
mysql:
username: meishesdk
password: 'Meishesdk2019'
path: 'bsedit.mysql.polardb.rds.aliyuncs.com:3306'
dbName: 'z-livebsedit-local'
config: 'charset=utf8mb4&parseTime=True&loc=Local'
maxIdleConns: 10
maxOpenConns: 10
logMode: false
#storage conf
storageConf:
#存储类型选择:aliyun,aws,local
defaultStorageType: "aliyun"
#存储文件的总目录,如:/meishe/2020/03/27/
pathDir: "meishe"
#通常只需要配置AliyunXXX,不需要配置AliyunTmpXXX
AliyunEndpoint:
AliyunBucket:
AliyunOriginHost:
AliyunHost:
AliyunAccessKey:
AliyunSecretKey:
AliyunAuthKey:
AliyunTmpEndpoint:
AliyunTmpBucket:
AliyunTmpOriginHost:
AliyunTmpHost:
AliyunTmpAccessKey:
AliyunTmpSecretKey:
AwsS3AccessKey:
AwsS3SecretKey:
AwsS3Region:
AwsS3Bucket:
AwsS3OriginHost:
AwsS3Host:
localHost: 'http://localhost:8888/livebsedit'
localBucket: 'livebsedit'
localPath: 'd:/home/tom/localpath/livebsedit'
#使用本地存储附加的路径
#1.当前日期为2020年03月27日17:38:36,路径为:2020/03/27/
pathPrefix: "1"
projectKey: project
videoKey: video
audioKey: audio
imageKey: image
videoCompiledKey: video-compiled
videoThumbnailKey: video-thumbnail
videoOnlyThumbnailKey: video-only-thumbnail
materialKey: material
recognitionKey: recognition
m3u8TransformKey: m3u8Transform
#cmd conf
cmdConf:
#通过ffmpeg合成命令:1.compileUrl 2.trimIn 3.trimOut 4.outPutPath
ffmpegCompileCmd: ffmpeg -protocol_whitelist file,http,https,tcp,tls -i %s -ss %f -t %f %s
#只转缩率图命令:1.转码结果输出路径 2.任务id 3.thumbnail-start-time时间,单位微秒 4.待转文件路径
onlyTranscodeThumbnailCmd: /home/tom/localpath/NvTranscoder
-o %s
--only-generate-thumbnails
--thumbnail-size 128
--thumbnail-interval 1000
--task-id %s
--thumbnail-start-time %d
%s
#video转码命令:1.转码结果输出路径 2.美摄m3u8的host 3.美摄m3u8的asset-uuid 4.taskId 5.待转文件路径
videoTranscodeCmd: /home/tom/localpath/NvTranscoder
-o %s
--slice-duration 5000
--video-size 480
--crf 27
--fps 25
--gop-size 25
--sample-rate 44100
--channel-count 2
--audio-bitrate 64000
--generate-thumbnails
--thumbnail-size 128
--thumbnail-interval 1000
--generate-cover
--cover-size 256
--cover-timestamp 0
--host %s
--asset-uuid %s
--callback-url http://localhost:8888
--task-id %s
--generate-waveform
--waveform-groups-per-second 150
--generate-audio-data
--multiple-audio-streams
--thumbnail-start-time 0
%s
- 开通开通3306 8888 端口