优化转码逻辑

This commit is contained in:
truewhile
2026-09-07 23:10:48 +08:00
parent 0e592105c4
commit c4b8114115
10 changed files with 314 additions and 45 deletions
+8 -2
View File
@@ -11,8 +11,9 @@ import (
)
type transcodeInput struct {
Source string
Headers map[string]string
Source string
Headers map[string]string
StartSec float64
}
type ffmpegArgSettings struct {
@@ -125,6 +126,11 @@ func baseFFmpegArgs(preInput string, realtime bool) []string {
func appendInputAndVideoArgs(args []string, input transcodeInput, settings ffmpegArgSettings, video ffmpegVideoPlan) []string {
args = append(args, ffmpegHTTPInputArgs(input)...)
// Input seek (-ss before -i) lets mid-file HLS restarts jump without
// decoding everything before the click position.
if input.StartSec > 0.05 {
args = append(args, "-ss", strconv.FormatFloat(input.StartSec, 'f', 3, 64))
}
args = append(args, "-i", input.Source, "-map", "0:v:0?", "-map", "0:a:0?", "-vf", video.filter, "-c:v", video.codec)
if settings.threads > 0 && video.codec == "libx264" {
args = append(args, "-threads", strconv.Itoa(settings.threads))