Retry hardware failures inline with software and avoid UI crash
This commit is contained in:
parent
f60b2a648b
commit
075f363872
44
main.go
44
main.go
|
|
@ -6209,23 +6209,23 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
if logFile != nil {
|
if logFile != nil {
|
||||||
fmt.Fprintf(logFile, "\nStatus: failed at %s\nError: %v\nStderr:\n%s\n", time.Now().Format(time.RFC3339), err, stderrOutput)
|
fmt.Fprintf(logFile, "\nStatus: failed at %s\nError: %v\nStderr:\n%s\n", time.Now().Format(time.RFC3339), err, stderrOutput)
|
||||||
}
|
}
|
||||||
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
// Detect hardware failure and retry once in software before surfacing error
|
||||||
errorExplanation := interpretFFmpegError(err)
|
resolvedAccel := effectiveHardwareAccel(s.convert)
|
||||||
var errorMsg error
|
isHardwareFailure := strings.Contains(stderrOutput, "No capable devices found") ||
|
||||||
|
strings.Contains(stderrOutput, "Cannot load") ||
|
||||||
|
strings.Contains(stderrOutput, "not available") &&
|
||||||
|
(strings.Contains(stderrOutput, "nvenc") ||
|
||||||
|
strings.Contains(stderrOutput, "amf") ||
|
||||||
|
strings.Contains(stderrOutput, "qsv") ||
|
||||||
|
strings.Contains(stderrOutput, "vaapi") ||
|
||||||
|
strings.Contains(stderrOutput, "videotoolbox"))
|
||||||
|
|
||||||
// Check if this is a hardware encoding failure
|
if isHardwareFailure && !hwFallbackTried && resolvedAccel != "none" && resolvedAccel != "" {
|
||||||
resolvedAccel := effectiveHardwareAccel(s.convert)
|
accelVal, _ := cfg["hardwareAccel"].(string)
|
||||||
isHardwareFailure := strings.Contains(stderrOutput, "No capable devices found") ||
|
if accelVal == "" {
|
||||||
strings.Contains(stderrOutput, "Cannot load") ||
|
accelVal = "auto"
|
||||||
strings.Contains(stderrOutput, "not available") &&
|
}
|
||||||
(strings.Contains(stderrOutput, "nvenc") ||
|
if !strings.EqualFold(accelVal, "none") {
|
||||||
strings.Contains(stderrOutput, "amf") ||
|
|
||||||
strings.Contains(stderrOutput, "qsv") ||
|
|
||||||
strings.Contains(stderrOutput, "vaapi") ||
|
|
||||||
strings.Contains(stderrOutput, "videotoolbox"))
|
|
||||||
|
|
||||||
// Auto-fallback to software and retry once if hardware fails
|
|
||||||
if isHardwareFailure && !hwFallbackTried && resolvedAccel != "none" && resolvedAccel != "" {
|
|
||||||
cfg["hardwareAccel"] = "none"
|
cfg["hardwareAccel"] = "none"
|
||||||
cfg["hwFallbackTried"] = true
|
cfg["hwFallbackTried"] = true
|
||||||
job.Config = cfg
|
job.Config = cfg
|
||||||
|
|
@ -6235,13 +6235,15 @@ func (s *appState) startConvert(status *widget.Label, btn, cancelBtn *widget.But
|
||||||
_ = logFile.Close()
|
_ = logFile.Close()
|
||||||
}
|
}
|
||||||
s.convertCancel = nil
|
s.convertCancel = nil
|
||||||
// Retry conversion in software
|
return s.executeConvertJob(ctx, job, progressCallback)
|
||||||
go func() {
|
|
||||||
_ = s.executeConvertJob(ctx, job, progressCallback)
|
|
||||||
}()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fyne.CurrentApp().Driver().DoFromGoroutine(func() {
|
||||||
|
errorExplanation := interpretFFmpegError(err)
|
||||||
|
var errorMsg error
|
||||||
|
|
||||||
|
// Check if this is a hardware encoding failure
|
||||||
if isHardwareFailure && resolvedAccel != "none" && resolvedAccel != "" {
|
if isHardwareFailure && resolvedAccel != "none" && resolvedAccel != "" {
|
||||||
chosen := s.convert.HardwareAccel
|
chosen := s.convert.HardwareAccel
|
||||||
if chosen == "" {
|
if chosen == "" {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user