mirror of
https://github.com/xfrr/goffmpeg.git
synced 2026-04-22 23:17:21 +08:00
ec40467798
* cleanup readme & examples * upgrade go version * add makefile with basic commands * add e2e test * add gha * update .gitignore
22 lines
393 B
Go
22 lines
393 B
Go
package duration
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func DurToSec(dur string) (sec float64) {
|
|
durAry := strings.Split(dur, ":")
|
|
var secs float64
|
|
if len(durAry) != 3 {
|
|
return
|
|
}
|
|
hr, _ := strconv.ParseFloat(durAry[0], 64)
|
|
secs = hr * (60 * 60)
|
|
min, _ := strconv.ParseFloat(durAry[1], 64)
|
|
secs += min * (60)
|
|
second, _ := strconv.ParseFloat(durAry[2], 64)
|
|
secs += second
|
|
return secs
|
|
}
|