外观
系统配置
本文详细介绍系统的各项配置选项。
配置文件
系统配置文件位于 server/configs/config.yaml:
yaml
# 应用基础配置
app:
name: mika-transcode
mode: release # debug / release
port: 7501
timezone: Asia/Shanghai
# 数据库配置
database:
host: localhost
port: 3306
user: mika
password: your_password
dbname: mika_transcode
charset: utf8mb4
max_idle_conns: 10
max_open_conns: 100
# Redis 配置
redis:
host: localhost
port: 6379
password: ""
db: 0
pool_size: 100
# JWT 配置
jwt:
secret: your-jwt-secret-key
expire: 86400 # 24 小时
refresh_expire: 604800 # 7 天
# 日志配置
log:
level: info # debug / info / warn / error
format: json # json / text
output: file # console / file
file_path: logs/app.log
max_size: 100 # MB
max_backups: 10
max_age: 30 # 天基础设置
站点配置
在 系统设置 → 基础设置 中配置:
| 配置项 | 说明 | 示例 |
|---|---|---|
| 站点名称 | 网站名称 | 米卡云转码 |
| 站点 URL | 网站地址 | https://example.com |
| 站点描述 | SEO 描述 | 专业视频转码平台 |
| 站点关键词 | SEO 关键词 | 视频转码,M3U8 |
| ICP 备案号 | 备案信息 | 京ICP备xxxxx号 |
| 版权信息 | 页脚版权 | © 2024 MikaCubes |
联系方式
yaml
contact:
email: support@example.com
qq: 123456789
wechat: mika_support
telegram: @mika_support转码设置
基础转码配置
yaml
transcode:
# FFmpeg 路径
ffmpeg_path: /usr/bin/ffmpeg
ffprobe_path: /usr/bin/ffprobe
# 默认输出配置
default:
resolution: 720p
video_bitrate: 2000 # kbps
audio_bitrate: 128 # kbps
segment_duration: 10 # 秒
# 转码队列
queue:
max_concurrent: 2 # 最大并发数
max_retries: 3 # 失败重试次数
retry_interval: 60 # 重试间隔 (秒)
timeout: 7200 # 超时时间 (秒)分辨率预设
yaml
transcode:
presets:
360p:
width: 640
height: 360
bitrate: 800
480p:
width: 854
height: 480
bitrate: 1200
720p:
width: 1280
height: 720
bitrate: 2500
1080p:
width: 1920
height: 1080
bitrate: 5000硬件加速
yaml
transcode:
hardware_accel:
enabled: true
type: auto # auto / nvidia / intel / amd
# NVIDIA 配置
nvidia:
encoder: h264_nvenc
decoder: h264_cuvid
# Intel 配置
intel:
encoder: h264_qsv
decoder: h264_qsv上传设置
文件上传限制
yaml
upload:
# 最大文件大小
max_size: 5368709120 # 5GB
# 允许的文件类型
allowed_types:
video:
- video/mp4
- video/x-msvideo
- video/x-matroska
- video/quicktime
image:
- image/jpeg
- image/png
- image/gif
- image/webp
# 临时文件保留时间 (小时)
temp_expire: 24
# 分片上传
chunk:
enabled: true
size: 5242880 # 5MB封面生成
yaml
cover:
# 自动生成封面
auto_generate: true
# 截取时间点 (秒)
time_offset: 5
# 封面尺寸
width: 640
height: 360
# 输出格式
format: jpg
quality: 85水印设置
图片水印
yaml
watermark:
image:
enabled: false
path: /path/to/watermark.png
position: bottom-right # 位置
opacity: 70 # 透明度 0-100
margin: 20 # 边距
scale: auto # auto / fixed文字水印
yaml
watermark:
text:
enabled: false
content: "© MikaCubes"
font: /path/to/font.ttf
size: 24
color: "#FFFFFF"
opacity: 50
position: bottom-right
margin: 20存储设置
本地存储
yaml
storage:
type: local
local:
root_path: /www/wwwroot/mika/app/public
video_path: videos
temp_path: temp
upload_path: uploads云存储
详见 存储配置 文档。
安全设置
访问控制
yaml
security:
# CORS 配置
cors:
enabled: true
allowed_origins:
- "https://example.com"
- "https://*.example.com"
allowed_methods:
- GET
- POST
- PUT
- DELETE
allowed_headers:
- Authorization
- Content-Type
max_age: 86400
# 请求限流
rate_limit:
enabled: true
requests: 100 # 请求数
duration: 60 # 时间窗口 (秒)
# IP 黑名单
ip_blacklist:
enabled: false
list: []API 密钥
yaml
api_key:
enabled: true
# 密钥有效期 (天)
expire_days: 365
# 请求签名
sign:
enabled: true
algorithm: sha256
expire: 300 # 签名有效期 (秒)防盗链
yaml
security:
hotlink:
enabled: true
allowed_referers:
- "example.com"
- "*.example.com"
allow_empty: false邮件设置
yaml
email:
enabled: true
smtp:
host: smtp.example.com
port: 465
username: noreply@example.com
password: your_password
encryption: ssl # ssl / tls / none
from:
name: 米卡云转码
address: noreply@example.com
# 邮件模板目录
template_path: templates/email通知设置
站内通知
yaml
notification:
# 转码完成通知
transcode_complete: true
# 存储空间预警
storage_warning: true
storage_warning_threshold: 90 # 百分比
# VIP 到期提醒
vip_expire_reminder: true
vip_expire_days: 7Webhook
yaml
webhook:
enabled: false
url: https://your-webhook-url.com
secret: your_webhook_secret
events:
- video.uploaded
- video.transcoded
- user.registered
- order.paid定时任务
yaml
cron:
# 清理临时文件
clean_temp:
enabled: true
schedule: "0 3 * * *" # 每天凌晨 3 点
# 统计数据汇总
statistics:
enabled: true
schedule: "0 1 * * *" # 每天凌晨 1 点
# VIP 到期检查
vip_expire:
enabled: true
schedule: "0 0 * * *" # 每天 0 点
# 数据库备份
db_backup:
enabled: false
schedule: "0 2 * * *"
backup_path: /backup/mysql
keep_days: 7性能优化
缓存配置
yaml
cache:
# 视频信息缓存
video:
enabled: true
ttl: 3600 # 秒
# 分类缓存
category:
enabled: true
ttl: 86400
# 用户信息缓存
user:
enabled: true
ttl: 1800
# 设置缓存
settings:
enabled: true
ttl: 3600数据库优化
yaml
database:
# 连接池
max_idle_conns: 10
max_open_conns: 100
conn_max_lifetime: 3600 # 秒
# 慢查询日志
slow_query:
enabled: true
threshold: 200 # 毫秒安装配置文件
系统安装完成后,会在 server/configs/ 目录下创建 install.json 文件:
json
{
"installed": true,
"installed_at": "2024-01-01T00:00:00Z",
"version": "2.0.0"
}重新安装
删除 install.json 文件并重启服务,即可再次进入安装引导页重新配置系统。
配置热更新
部分配置支持热更新,无需重启服务:
- 转码设置
- 水印设置
- 上传限制
- 缓存设置
在管理后台修改配置后,点击 立即生效 即可。
配置备份
导出配置
在 系统设置 → 配置管理 中导出:
- 点击 导出配置
- 选择导出范围
- 下载配置文件
导入配置
- 点击 导入配置
- 上传配置文件
- 预览变更
- 确认导入