Enable hardware accel but nothing improves the performance over libx264, and in some cases--like vulkan--it was slower. Tryed some of the amdgpu-install and h264_amf support but it relies on Ubuntu 24.

master
Zed A. Shaw 1 month ago
parent be44bcec22
commit e86695d903
  1. 4
      config.json
  2. 1
      config/settings.go
  3. 19
      main.go

@ -31,8 +31,8 @@
], ],
"CRF": 30, "CRF": 30,
"FPS": 30, "FPS": 30,
"Input": "test*.mp4", "Input": "LGoTHW/*.mp4",
"OutDir": "dash_test", "OutDir": "LGoTHW_DASH",
"Passes": 1, "Passes": 1,
"Dash": true, "Dash": true,
"Extras": [ "Extras": [

@ -26,6 +26,7 @@ type EncodeOpts struct {
Dash bool Dash bool
CRF int CRF int
FPS int FPS int
HardwareAccel string
Tune string Tune string
Input string Input string
OutDir string OutDir string

@ -63,6 +63,8 @@ func Run(encoding config.EncodeOpts, codec config.CodecOpts, pass int, pid int,
"-pix_fmt", "yuv420p", "-pix_fmt", "yuv420p",
} }
in_extras := []string{}
if encoding.Passes > 1 { if encoding.Passes > 1 {
extras = append(extras, extras = append(extras,
"-pass", fmt.Sprint(pass), "-pass", fmt.Sprint(pass),
@ -88,10 +90,14 @@ func Run(encoding config.EncodeOpts, codec config.CodecOpts, pass int, pid int,
} }
if encoding.Test > 0 { if encoding.Test > 0 {
encode.InputOptions("-ss", fmt.Sprintf("00:%d", encoding.TestStart)) in_extras = append(in_extras, "-ss", fmt.Sprintf("00:%d", encoding.TestStart))
extras = append(extras, "-t", fmt.Sprint(encoding.Test)) extras = append(extras, "-t", fmt.Sprint(encoding.Test))
} }
if encoding.HardwareAccel != "" {
in_extras = append(in_extras, "-hwaccel", encoding.HardwareAccel)
}
if codec.VideoCodec == "none" { if codec.VideoCodec == "none" {
extras = append(extras, "-vn") extras = append(extras, "-vn")
} else { } else {
@ -107,6 +113,7 @@ func Run(encoding config.EncodeOpts, codec config.CodecOpts, pass int, pid int,
extras = append(extras, "-dash", "1") extras = append(extras, "-dash", "1")
} }
encode.InputOptions(in_extras...)
encode.OutputOptions(extras...) encode.OutputOptions(extras...)
cmd := encode.InputPath(input). cmd := encode.InputPath(input).
@ -164,8 +171,10 @@ func RenderFile(encoding config.EncodeOpts, pid int, source_path string, force b
Run(encoding, *codec, encoding.Passes, pid, source_path, codec.Target) Run(encoding, *codec, encoding.Passes, pid, source_path, codec.Target)
} }
if encoding.Dash {
SaveMPD(source_path, encoding) SaveMPD(source_path, encoding)
} }
}
func StrSeq(up_to int) iter.Seq[string] { func StrSeq(up_to int) iter.Seq[string] {
return func (yield func(x string) bool) { return func (yield func(x string) bool) {
@ -221,18 +230,22 @@ func SaveMPD(source_path string, encoding config.EncodeOpts) {
out, err := ffmpeg.CombinedOutput() out, err := ffmpeg.CombinedOutput()
os.Stdout.Write(out) os.Stdout.Write(out)
log.Fatal(err)
if err != nil { log.Fatal(err) }
} }
func RenderToDir(encoding config.EncodeOpts, force bool) { func RenderToDir(encoding config.EncodeOpts, force bool) {
matches, err := filepath.Glob(encoding.Input) matches, err := filepath.Glob(encoding.Input)
if err != nil { log.Fatalf("%v", err) } if err != nil { log.Fatal(err) }
for _, source_path := range matches { for _, source_path := range matches {
// BUG: glob will return these even if it's not in the regex
if source_path != "." || source_path != ".." {
RenderFile(encoding, rand.Int(), source_path, force) RenderFile(encoding, rand.Int(), source_path, force)
} }
} }
}
func main() { func main() {
settings := config.Load() settings := config.Load()

Loading…
Cancel
Save