From 0fb852e034269d7904f0653ad23128e0e12fc7b5 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Fri, 27 Dec 2024 20:59:04 +0200 Subject: [PATCH] fix: don't gracefully exit on a progress=end with a total_size of 0. this is likely a nonzero exit --- progress.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/progress.go b/progress.go index b5fcd80..ef846a7 100644 --- a/progress.go +++ b/progress.go @@ -42,6 +42,7 @@ func TempSock(totalDuration float64, teaP *tea.Program) string { go func() { re := regexp.MustCompile(`out_time_ms=(\d+)`) speedRe := regexp.MustCompile(`speed=(\d+\.\d+x)`) + totalSizeRe := regexp.MustCompile(`total_size=(\d+)`) fd, err := l.Accept() if err != nil { @@ -65,6 +66,12 @@ func TempSock(totalDuration float64, teaP *tea.Program) string { cp = fmt.Sprintf("%.2f", float64(c)/totalDuration/1000000) } if strings.Contains(data, "progress=end") { + totalSize := totalSizeRe.FindString(data) + if len(totalSize) > 0 && strings.Split(totalSize, "=")[1] == "0" { + // Command failed. Don't send a finishedEncodingVideo message. + // encode() will take care of reporting the error. + continue + } cp = "done" teaP.Send(finishedEncodingVideo{}) return