Версия 0.8.0 #9
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user