功能完善
UI改进
This commit is contained in:
+29
-10
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
@@ -141,6 +142,24 @@ func escapeFilterPath(path string) string {
|
||||
return s
|
||||
}
|
||||
|
||||
// qualityArg maps a CRF-like quality value to encoder-specific arguments.
|
||||
// Software encoders use -crf, NVENC uses -cq, QSV uses -global_quality,
|
||||
// and AMF uses -qp_i/-qp_p for constant-quality encoding.
|
||||
func qualityArg(codec string, crf int) []string {
|
||||
v := strconv.Itoa(crf)
|
||||
lower := strings.ToLower(codec)
|
||||
switch {
|
||||
case strings.Contains(lower, "nvenc"):
|
||||
return []string{"-cq", v}
|
||||
case strings.Contains(lower, "qsv"):
|
||||
return []string{"-global_quality", v}
|
||||
case strings.Contains(lower, "amf"):
|
||||
return []string{"-qp_i", v, "-qp_p", v}
|
||||
default:
|
||||
return []string{"-crf", v}
|
||||
}
|
||||
}
|
||||
|
||||
func tailLines(s string, n int) string {
|
||||
lines := strings.Split(s, "\n")
|
||||
if len(lines) > n {
|
||||
@@ -197,11 +216,11 @@ func BuildEncodeArgs(input string, output string, s EncodeSettings, hwAccel stri
|
||||
|
||||
args = append(args, "-i", input)
|
||||
|
||||
if s.HWEncoder != "" {
|
||||
args = append(args, "-c:v", s.HWEncoder)
|
||||
} else {
|
||||
args = append(args, "-c:v", s.VideoCodec)
|
||||
codec := s.HWEncoder
|
||||
if codec == "" {
|
||||
codec = s.VideoCodec
|
||||
}
|
||||
args = append(args, "-c:v", codec)
|
||||
|
||||
if s.Preset != "" {
|
||||
// libx* uses named presets (fast, medium…), HW encoders use p1–p7
|
||||
@@ -209,7 +228,7 @@ func BuildEncodeArgs(input string, output string, s EncodeSettings, hwAccel stri
|
||||
}
|
||||
|
||||
if s.CRF > 0 {
|
||||
args = append(args, "-crf", fmt.Sprintf("%d", s.CRF))
|
||||
args = append(args, qualityArg(codec, s.CRF)...)
|
||||
} else if s.VideoBitrate != "" {
|
||||
args = append(args, "-b:v", s.VideoBitrate)
|
||||
}
|
||||
@@ -327,16 +346,16 @@ func BuildSubtitleArgs(input string, output string, s SubtitleSettings, encode E
|
||||
args = append(args, "-vf", strings.Join(subFilters, ","))
|
||||
}
|
||||
|
||||
if encode.HWEncoder != "" {
|
||||
args = append(args, "-c:v", encode.HWEncoder)
|
||||
} else {
|
||||
args = append(args, "-c:v", encode.VideoCodec)
|
||||
codec := encode.HWEncoder
|
||||
if codec == "" {
|
||||
codec = encode.VideoCodec
|
||||
}
|
||||
args = append(args, "-c:v", codec)
|
||||
if encode.Preset != "" {
|
||||
args = append(args, "-preset", encode.Preset)
|
||||
}
|
||||
if encode.CRF > 0 {
|
||||
args = append(args, "-crf", fmt.Sprintf("%d", encode.CRF))
|
||||
args = append(args, qualityArg(codec, encode.CRF)...)
|
||||
} else if encode.VideoBitrate != "" {
|
||||
args = append(args, "-b:v", encode.VideoBitrate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user