mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 04:26:38 +08:00
fix: enforce transcoding resource controls
This commit is contained in:
@@ -37,6 +37,10 @@ func ApplyRuntimeSetting(cfg *config.Config, key, value string) {
|
||||
cfg.App.FFmpegPath = value
|
||||
case "ffprobe.path", "app.ffprobe_path":
|
||||
cfg.App.FFprobePath = value
|
||||
case "transcode.enabled", "transcoder.enabled":
|
||||
cfg.Transcoder.Enabled = parseBoolSetting(value, true)
|
||||
case "transcode.hw_enabled", "transcoder.hardware_accel":
|
||||
cfg.Transcoder.HardwareAccel = parseBoolSetting(value, false)
|
||||
case "transcode.hw_accel", "transcoder.encoder":
|
||||
switch value {
|
||||
case "", "auto", "none", "software":
|
||||
@@ -48,6 +52,20 @@ func ApplyRuntimeSetting(cfg *config.Config, key, value string) {
|
||||
if n, err := strconv.Atoi(value); err == nil {
|
||||
cfg.Transcoder.MaxHeight = n
|
||||
}
|
||||
case "transcode.max_jobs", "transcoder.max_concurrent":
|
||||
if n, err := strconv.Atoi(value); err == nil {
|
||||
cfg.Transcoder.MaxConcurrent = n
|
||||
}
|
||||
case "transcode.realtime", "transcoder.realtime":
|
||||
cfg.Transcoder.Realtime = parseBoolSetting(value, true)
|
||||
case "transcode.threads", "transcoder.threads":
|
||||
if n, err := strconv.Atoi(value); err == nil {
|
||||
cfg.Transcoder.Threads = n
|
||||
}
|
||||
case "transcode.idle_timeout_seconds", "transcoder.idle_timeout_seconds":
|
||||
if n, err := strconv.Atoi(value); err == nil {
|
||||
cfg.Transcoder.IdleTimeoutSeconds = n
|
||||
}
|
||||
case "transcode.video_bitrate", "transcoder.video_bitrate":
|
||||
cfg.Transcoder.VideoBitrate = value
|
||||
case "license.server_url":
|
||||
@@ -56,3 +74,14 @@ func ApplyRuntimeSetting(cfg *config.Config, key, value string) {
|
||||
cfg.License.HMACSecret = value
|
||||
}
|
||||
}
|
||||
|
||||
func parseBoolSetting(value string, fallback bool) bool {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "1", "true", "yes", "on", "enabled", "启用", "开启":
|
||||
return true
|
||||
case "0", "false", "no", "off", "disabled", "禁用", "关闭":
|
||||
return false
|
||||
default:
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user