Get the ffmpeg command regardless of the platform

This commit is contained in:
frr
2018-02-27 13:58:56 +01:00
parent aa676ed4f3
commit 2e2a6c763c
3 changed files with 79 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"strings"
"strconv"
"goffmpeg/models"
"runtime"
)
func DurToSec(dur string) (sec float64) {
@@ -21,6 +22,70 @@ func DurToSec(dur string) (sec float64) {
return secs
}
func GetExec() string {
var platform = runtime.GOOS
var command = ""
switch platform {
case "windows":
command = "cmd"
break
default:
command = "/bin/sh"
break
}
return command
}
func GetExecArgs() string {
var platform = runtime.GOOS
var args = ""
switch platform {
case "windows":
args = "/C"
break
default:
args = "-c"
break
}
return args
}
func GetFFmpegExec() string {
var platform = runtime.GOOS
var command = ""
switch platform {
case "windows":
command = "where ffmpeg"
break
default:
command = "which ffmpeg"
break
}
return command
}
func GetFFprobeExec() string {
var platform = runtime.GOOS
var command = ""
switch platform {
case "windows":
command = "where ffprobe"
break
default:
command = "which ffprobe"
break
}
return command
}
func CheckFileType(streams []models.Streams) string {
for i := 0; i < len(streams); i++ {
st := streams[i]