Версия 0.8.0 #9

Merged
kor-elf merged 15 commits from develop into main 2025-05-11 19:45:40 +05:00
Showing only changes of commit da7d9c8035 - Show all commits

View File

@ -11,6 +11,7 @@ import (
"regexp"
"strconv"
"strings"
"unicode"
)
type File struct {
@ -126,7 +127,13 @@ func (s Convertor) GetTotalDuration(file *File) (duration float64, err error) {
if len(frames) == 0 {
return s.getAlternativeTotalDuration(file)
}
return strconv.ParseFloat(frames, 64)
duration, err = strconv.ParseFloat(frames, 64)
if err != nil {
// fix .mts duration
return strconv.ParseFloat(getFirstDigits(frames), 64)
}
return duration, err
}
func (s Convertor) getAlternativeTotalDuration(file *File) (duration float64, err error) {
@ -241,3 +248,15 @@ func (s Convertor) GetSupportFormats() (encoder.ConvertorFormatsContract, error)
func (s Convertor) GetRunningProcesses() map[int]*exec.Cmd {
return s.runningProcesses.items
}
func getFirstDigits(s string) string {
result := ""
for _, r := range s {
if unicode.IsDigit(r) {
result += string(r)
} else {
break
}
}
return result
}