fix: don't gracefully exit on a progress=end with a total_size of 0. this is likely a nonzero exit

This commit is contained in:
2024-12-27 20:59:04 +02:00
parent 36f648fd86
commit 0fb852e034
+7
View File
@@ -42,6 +42,7 @@ func TempSock(totalDuration float64, teaP *tea.Program) string {
go func() { go func() {
re := regexp.MustCompile(`out_time_ms=(\d+)`) re := regexp.MustCompile(`out_time_ms=(\d+)`)
speedRe := regexp.MustCompile(`speed=(\d+\.\d+x)`) speedRe := regexp.MustCompile(`speed=(\d+\.\d+x)`)
totalSizeRe := regexp.MustCompile(`total_size=(\d+)`)
fd, err := l.Accept() fd, err := l.Accept()
if err != nil { if err != nil {
@@ -65,6 +66,12 @@ func TempSock(totalDuration float64, teaP *tea.Program) string {
cp = fmt.Sprintf("%.2f", float64(c)/totalDuration/1000000) cp = fmt.Sprintf("%.2f", float64(c)/totalDuration/1000000)
} }
if strings.Contains(data, "progress=end") { 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" cp = "done"
teaP.Send(finishedEncodingVideo{}) teaP.Send(finishedEncodingVideo{})
return return